From c2365f8692f0504ad097b88088e80b1de56fdf9a Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Fri, 16 Aug 2024 21:22:26 +0530 Subject: [PATCH] use arch in makefile (#393) --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a9740f4c7..08d14a0ab 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,8 @@ ifeq ($(type), deb) image_base="ubuntu" image_tag="20.04" endif - +# Set arch to linux/amd64 if it's not defined +arch ?= linux/amd64 buildx=0 cache_from=type=local,src=/tmp/.buildx-cache cache_to=type=local,dest=/tmp/.buildx-cache @@ -54,6 +55,7 @@ define build --build-arg IMAGE_BASE=$(image_base) \ --build-arg IMAGE_TAG=$(image_tag) \ --build-arg CODE_PATH=$(4) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef else @@ -69,6 +71,7 @@ define build --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef endif @@ -87,6 +90,7 @@ define build_runtime --build-arg IMAGE_BASE=$(image_base) \ --build-arg IMAGE_TAG=$(image_tag) \ --build-arg CODE_PATH=$(4) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef else @@ -101,6 +105,7 @@ define build_runtime --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef endif @@ -118,6 +123,7 @@ define build-image --build-arg OPENRESTY_NAME=$(4) \ --build-arg OPENRESTY_VERSION=$(5) \ --build-arg CODE_PATH=$(6) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef else @@ -129,6 +135,7 @@ define build-image --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef endif @@ -145,6 +152,7 @@ define package --build-arg PACKAGE_TYPE=$(2) \ --build-arg OPENRESTY=$(openresty) \ --build-arg ARTIFACT=$(artifact) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.package.$(1) . docker run -d --rm --name output --net="host" apache/$(1)-packaged-$(2):$(version) docker cp output:/output ${PWD} @@ -164,6 +172,7 @@ define package_runtime --build-arg PACKAGE_TYPE=$(2) \ --build-arg OPENRESTY=$(openresty) \ --build-arg ARTIFACT=$(artifact) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.package.$(1) . docker run -d --rm --name output --net="host" apache/$(1)-packaged-$(2):$(runtime_version) docker cp output:/output ${PWD} @@ -290,13 +299,14 @@ package-apisix-base-deb: .PHONY: build-fpm ifneq ($(buildx), True) build-fpm: - docker build -t api7/fpm - < ./dockerfiles/Dockerfile.fpm + docker build --platform $(arch) -t api7/fpm - < ./dockerfiles/Dockerfile.fpm else build-fpm: docker buildx build \ --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -t api7/fpm - < ./dockerfiles/Dockerfile.fpm endif