From 3911fbab0c6153a4e3c3f54323c16a8ad113e78f Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 2 Jan 2024 21:49:31 +0930 Subject: [PATCH 1/2] fix(docker-buildx): use correct buidx variable for cross-compilation `BUILDPLATFORM` is the architecture for the machine building the image. this var is not for cross-compilation. `TARGETPLATFORM` is the correct variable to use for cross-compilation. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e89853d2..b9a79001 100644 --- a/Makefile +++ b/Makefile @@ -92,9 +92,9 @@ docker-push: ## Push docker image with the manager. # To properly provided solutions that supports more than one platform you should use this option. PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le .PHONY: docker-buildx -docker-buildx: test ## Build and push docker image for the manager for cross-platform support - # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile - sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross +docker-buildx: ## Build and push docker image for the manager for cross-platform support + # copy existing Dockerfile and insert --platform=${TARGETPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile + sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{TARGETPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{TARGETPLATFORM\}/' Dockerfile > Dockerfile.cross - docker buildx create --name project-v3-builder docker buildx use project-v3-builder - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . From 69e889bedf29e398e33e850828ae1a9212712a2a Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 8 Jan 2024 02:07:43 +0930 Subject: [PATCH 2/2] refactor: remove actions that do the same things as if they never existed in the first place The editing of the dockerfile is not required as specifying the platform in the `FROM` statement is already done by default. These lines of code are useless --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b9a79001..d09b9315 100644 --- a/Makefile +++ b/Makefile @@ -93,13 +93,10 @@ docker-push: ## Push docker image with the manager. PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le .PHONY: docker-buildx docker-buildx: ## Build and push docker image for the manager for cross-platform support - # copy existing Dockerfile and insert --platform=${TARGETPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile - sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{TARGETPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{TARGETPLATFORM\}/' Dockerfile > Dockerfile.cross - docker buildx create --name project-v3-builder docker buildx use project-v3-builder - - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . + - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile . - docker buildx rm project-v3-builder - rm Dockerfile.cross ##@ Deployment