[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.
This commit is contained in:
Timofei Larkin
2025-05-12 13:08:00 +04:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -9,6 +9,8 @@ image: image-cozystack-controller update-version
image-cozystack-controller:
docker buildx build -f images/cozystack-controller/Dockerfile ../../.. \
--provenance false \
--builder=$(BUILDER) \
--platform=$(PLATFORM) \
--tag $(REGISTRY)/cozystack-controller:$(call settag,$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/cozystack-controller:latest \
--cache-to type=inline \

View File

@@ -14,3 +14,9 @@ ifeq ($(COZYSTACK_VERSION),)
$(shell git fetch upstream --tags)
COZYSTACK_VERSION = $(patsubst v%,%,$(shell git describe --tags))
endif
# Get the name of the selected docker buildx builder
BUILDER ?= $(shell docker buildx inspect --bootstrap | head -n2 | awk '/^Name:/{print $$NF}')
# Get platforms supported by the builder
PLATFORM ?= $(shell docker buildx ls --format=json | jq -r 'select(.Name == "$(BUILDER)") | [.Nodes[].Platforms // []] | flatten | unique | map(select(test("^linux/amd64$$|^linux/arm64$$"))) | join(",")')