Skip to content

Commit

Permalink
use arch in makefile (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
Revolyssup authored Aug 16, 2024
1 parent ab17900 commit c2365f8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -69,6 +71,7 @@ define build
--load \
--cache-from=$(cache_from) \
--cache-to=$(cache_to) \
--platform $(arch) \
-f ./dockerfiles/Dockerfile.$(2).$(3) .
endef
endif
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c2365f8

Please sign in to comment.