@@ -261,7 +261,7 @@ endif
261
261
262
262
clean :
263
263
$(SUDO ) docker rmi $(IMAGE_NAMES ) > /dev/null 2>&1 || true
264
- rm -rf -- $(UPTODATE_FILES ) $(EXES ) .cache $( PACKAGES ) dist/ *
264
+ rm -rf -- $(UPTODATE_FILES ) $(EXES ) .cache dist
265
265
go clean ./...
266
266
267
267
clean-protos :
@@ -304,33 +304,34 @@ web-serve:
304
304
cd website && hugo --config config.toml --minify -v server
305
305
306
306
# Generate binaries for a Cortex release
307
- dist dist/cortex-linux-amd64 dist/cortex-darwin-amd64 dist/query-tee-linux-amd64 dist/query-tee-darwin-amd64 dist/cortex-linux-amd64-sha-256 dist/cortex-darwin-amd64-sha-256 dist/query-tee-linux-amd64-sha-256 dist/query-tee-darwin-amd64-sha-256 :
307
+ dist : dist/$(UPTODATE )
308
+
309
+ dist/$(UPTODATE ) :
308
310
rm -fr ./dist
309
311
mkdir -p ./dist
310
- GOOS=" linux" GOARCH=" amd64" CGO_ENABLED=0 go build $(GO_FLAGS ) -o ./dist/cortex-linux-amd64 ./cmd/cortex
311
- GOOS=" darwin" GOARCH=" amd64" CGO_ENABLED=0 go build $(GO_FLAGS ) -o ./dist/cortex-darwin-amd64 ./cmd/cortex
312
- GOOS=" linux" GOARCH=" amd64" CGO_ENABLED=0 go build $(GO_FLAGS ) -o ./dist/query-tee-linux-amd64 ./cmd/query-tee
313
- GOOS=" darwin" GOARCH=" amd64" CGO_ENABLED=0 go build $(GO_FLAGS ) -o ./dist/query-tee-darwin-amd64 ./cmd/query-tee
314
- sha256sum ./dist/cortex-darwin-amd64 | cut -d ' ' -f 1 > ./dist/cortex-darwin-amd64-sha-256
315
- sha256sum ./dist/cortex-linux-amd64 | cut -d ' ' -f 1 > ./dist/cortex-linux-amd64-sha-256
316
- sha256sum ./dist/query-tee-darwin-amd64 | cut -d ' ' -f 1 > ./dist/query-tee-darwin-amd64-sha-256
317
- sha256sum ./dist/query-tee-linux-amd64 | cut -d ' ' -f 1 > ./dist/query-tee-linux-amd64-sha-256
312
+ for os in linux darwin; do \
313
+ for arch in amd64 arm64; do \
314
+ echo "Building Cortex for $$os/$$arch"; \
315
+ GOOS =$$os GOARCH=$$arch CGO_ENABLED=0 go build $(GO_FLAGS ) -o ./dist/cortex-$$os-$$arch ./cmd/cortex; \
316
+ sha256sum ./dist/cortex-$$os-$$arch | cut -d ' ' -f 1 > ./dist/cortex-$$os-$$arch-sha-256; \
317
+ echo "Building query-tee for $$os/$$arch"; \
318
+ GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build $(GO_FLAGS ) -o ./dist/query-tee-$$os-$$arch ./cmd/query-tee; \
319
+ sha256sum ./dist/query-tee-$$os-$$arch | cut -d ' ' -f 1 > ./dist/query-tee-$$os-$$arch-sha-256; \
320
+ done; \
321
+ done; \
322
+ touch $@
318
323
319
324
# Generate packages for a Cortex release.
320
325
FPM_OPTS := fpm -s dir -v $(VERSION ) -n cortex -f \
321
326
--license "Apache 2.0" \
322
327
--url "https://github.com/cortexproject/cortex"
323
328
324
- FPM_ARGS := dist/cortex-linux-amd64=/usr/local/bin/cortex \
325
- docs/configuration/single-process-config.yaml=/etc/cortex/single-process-config.yaml\
326
-
327
- PACKAGES := dist/cortex-$(VERSION ) .rpm dist/cortex-$(VERSION ) .deb
328
329
PACKAGE_IN_CONTAINER := true
329
330
PACKAGE_IMAGE ?= $(IMAGE_PREFIX ) fpm
330
331
ifeq ($(PACKAGE_IN_CONTAINER ) , true)
331
332
332
333
.PHONY : packages
333
- packages : dist/cortex-linux-amd64 packaging/fpm/$(UPTODATE )
334
+ packages : dist packaging/fpm/$(UPTODATE )
334
335
@mkdir -p $(shell pwd) /.pkg
335
336
@mkdir -p $(shell pwd) /.cache
336
337
@echo " >>>> Entering build container: $@ "
@@ -340,27 +341,53 @@ packages: dist/cortex-linux-amd64 packaging/fpm/$(UPTODATE)
340
341
341
342
else
342
343
343
- packages : $(PACKAGES )
344
-
345
- dist/% .deb : dist/cortex-linux-amd64 $(wildcard packaging/deb/** )
346
- $(FPM_OPTS ) -t deb \
347
- --after-install packaging/deb/control/postinst \
348
- --before-remove packaging/deb/control/prerm \
349
- --package $@ $(FPM_ARGS ) \
350
- packaging/deb/default/cortex=/etc/default/cortex \
351
- packaging/deb/systemd/cortex.service=/etc/systemd/system/cortex.service
352
- sha256sum ./dist/cortex-$(VERSION ) .deb | cut -d ' ' -f 1 > ./dist/cortex-$(VERSION ) .deb-sha-256
353
-
354
- dist/% .rpm : dist/cortex-linux-amd64 $(wildcard packaging/rpm/** )
355
- $(FPM_OPTS ) -t rpm \
356
- --after-install packaging/rpm/control/post \
357
- --before-remove packaging/rpm/control/preun \
358
- --package $@ $(FPM_ARGS ) \
359
- packaging/rpm/sysconfig/cortex=/etc/sysconfig/cortex \
360
- packaging/rpm/systemd/cortex.service=/etc/systemd/system/cortex.service
361
- sha256sum ./dist/cortex-$(VERSION ) .rpm | cut -d ' ' -f 1 > ./dist/cortex-$(VERSION ) .rpm-sha-256
344
+ packages : dist/$(UPTODATE ) -packages
345
+
346
+ dist/$(UPTODATE ) -packages : dist $(wildcard packaging/deb/** ) $(wildcard packaging/rpm/** )
347
+ for arch in amd64 arm64; do \
348
+ rpm_arch=x86_64; \
349
+ deb_arch=x86_64; \
350
+ if [ "$$arch" = "arm64" ]; then \
351
+ rpm_arch=aarch64; \
352
+ deb_arch=arm64; \
353
+ fi; \
354
+ $(FPM_OPTS) -t deb \
355
+ --architecture $$deb_arch \
356
+ --after-install packaging/deb/control/postinst \
357
+ --before-remove packaging/deb/control/prerm \
358
+ --package dist/cortex-$(VERSION)_$$arch.deb \
359
+ dist/cortex-linux-$$arch=/usr/local/bin/cortex \
360
+ docs/configuration/single-process-config.yaml=/etc/cortex/single-process-config.yaml \
361
+ packaging/deb/default/cortex=/etc/default/cortex \
362
+ packaging/deb/systemd/cortex.service=/etc/systemd/system/cortex.service; \
363
+ $(FPM_OPTS) -t rpm \
364
+ --architecture $$rpm_arch \
365
+ --after-install packaging/rpm/control/post \
366
+ --before-remove packaging/rpm/control/preun \
367
+ --package dist/cortex-$(VERSION)_$$arch.rpm \
368
+ dist/cortex-linux-$$arch=/usr/local/bin/cortex \
369
+ docs/configuration/single-process-config.yaml=/etc/cortex/single-process-config.yaml \
370
+ packaging/rpm/sysconfig/cortex=/etc/sysconfig/cortex \
371
+ packaging/rpm/systemd/cortex.service=/etc/systemd/system/cortex.service; \
372
+ done
373
+ for pkg in dist/*.deb dist/*.rpm; do \
374
+ sha256sum $$pkg | cut -d ' ' -f 1 > $${pkg}-sha-256; \
375
+ done; \
376
+ touch $@
377
+
362
378
endif
363
379
380
+ # Build both arm64 and amd64 images, so that we can test deb/rpm packages for both architectures.
381
+ packaging/rpm/centos-systemd/$(UPTODATE ) : packaging/rpm/centos-systemd/Dockerfile
382
+ $(SUDO ) docker build --platform linux/amd64 --build-arg=revision=$(GIT_REVISION ) --build-arg=goproxyValue=$(GOPROXY_VALUE ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) :amd64 $(@D ) /
383
+ $(SUDO ) docker build --platform linux/arm64 --build-arg=revision=$(GIT_REVISION ) --build-arg=goproxyValue=$(GOPROXY_VALUE ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) :arm64 $(@D ) /
384
+ touch $@
385
+
386
+ packaging/deb/debian-systemd/$(UPTODATE ) : packaging/deb/debian-systemd/Dockerfile
387
+ $(SUDO ) docker build --platform linux/amd64 --build-arg=revision=$(GIT_REVISION ) --build-arg=goproxyValue=$(GOPROXY_VALUE ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) :amd64 $(@D ) /
388
+ $(SUDO ) docker build --platform linux/arm64 --build-arg=revision=$(GIT_REVISION ) --build-arg=goproxyValue=$(GOPROXY_VALUE ) -t $(IMAGE_PREFIX )$(shell basename $(@D ) ) :arm64 $(@D ) /
389
+ touch $@
390
+
364
391
.PHONY : test-packages
365
392
test-packages : packages packaging/rpm/centos-systemd/$(UPTODATE ) packaging/deb/debian-systemd/$(UPTODATE )
366
393
./tools/packaging/test-packages $(IMAGE_PREFIX ) $(VERSION )
0 commit comments