Skip to content

Commit 653e2bc

Browse files
authored
[519] Cross-arch builds: builders variables (#907)
Added PLATFORM variable to `common-envs.mk`: if not defined, it is calculated based on docker daemon arch. May be overridden by e.g. `make -e PLATFORM='linux/arm64' ...` Added the variable to a single Dockerfile for now.
2 parents 557ffa5 + 2349ff6 commit 653e2bc

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/system/cozystack-controller/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ image: image-cozystack-controller update-version
99
image-cozystack-controller:
1010
docker buildx build -f images/cozystack-controller/Dockerfile ../../.. \
1111
--provenance false \
12+
--builder=$(BUILDER) \
13+
--platform=$(PLATFORM) \
1214
--tag $(REGISTRY)/cozystack-controller:$(call settag,$(TAG)) \
1315
--cache-from type=registry,ref=$(REGISTRY)/cozystack-controller:latest \
1416
--cache-to type=inline \

‎scripts/common-envs.mk‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ ifeq ($(COZYSTACK_VERSION),)
1414
$(shell git fetch upstream --tags)
1515
COZYSTACK_VERSION = $(patsubst v%,%,$(shell git describe --tags))
1616
endif
17+
18+
# Get the name of the selected docker buildx builder
19+
BUILDER ?= $(shell docker buildx inspect --bootstrap | head -n2 | awk '/^Name:/{print $$NF}')
20+
# Get platforms supported by the builder
21+
PLATFORM ?= $(shell docker buildx ls --format=json | jq -r 'select(.Name == "$(BUILDER)") | [.Nodes[].Platforms // []] | flatten | unique | map(select(test("^linux/amd64$$|^linux/arm64$$"))) | join(",")')
22+

0 commit comments

Comments
 (0)