@@ -134,41 +134,47 @@ push-multiarch-dev-on-debian:
134134 @$(call func_echo_success_status, "$@ -> [ Done ]")
135135
136136
137- # ## push-multiarch-on-ubuntu : Push apache/apisix:xx-ubuntu image
138- .PHONY : push-multiarch-on-ubuntu
139- push-multiarch-on-ubuntu :
137+ # $(1): platform, $(2): extra buildx flags (e.g. --push)
138+ define func_multiarch_build
140139 @$(call func_echo_status, "$@ -> [ Start ]")
141- cp ./utils/* .sh ubuntu/
142- $(ENV_DOCKER ) buildx build --network=host --push \
143- -t $(ENV_APISIX_IMAGE_TAG_NAME ) -ubuntu \
140+ $( if $( filter-out redhat, $( 1 ) ) , cp ./utils/* .sh $( 1 ) /)
141+ $(ENV_DOCKER ) buildx build --network=host $( 2 ) \
142+ -t $(ENV_APISIX_IMAGE_TAG_NAME ) -$( 1 ) \
144143 --platform linux/amd64,linux/arm64 \
145- -f ./ubuntu /Dockerfile ubuntu
146- rm -f ubuntu /* .sh
144+ -f ./$( 1 ) /Dockerfile $( 1 )
145+ $( if $( filter-out redhat, $( 1 ) ) , rm -f $( 1 ) /* .sh)
147146 @$(call func_echo_success_status, "$@ -> [ Done ]")
147+ endef
148+
149+ # ## build-multiarch-on-ubuntu : Build apache/apisix:xx-ubuntu multiarch image
150+ .PHONY : build-multiarch-on-ubuntu
151+ build-multiarch-on-ubuntu :
152+ $(call func_multiarch_build,ubuntu,)
153+
154+ # ## push-multiarch-on-ubuntu : Push apache/apisix:xx-ubuntu image
155+ .PHONY : push-multiarch-on-ubuntu
156+ push-multiarch-on-ubuntu :
157+ $(call func_multiarch_build,ubuntu,--push)
148158
159+ # ## build-multiarch-on-debian : Build apache/apisix:xx-debian multiarch image
160+ .PHONY : build-multiarch-on-debian
161+ build-multiarch-on-debian :
162+ $(call func_multiarch_build,debian,)
149163
150164# ## push-multiarch-on-debian : Push apache/apisix:xx-debian image
151165.PHONY : push-multiarch-on-debian
152166push-multiarch-on-debian :
153- @$(call func_echo_status, "$@ -> [ Start ]")
154- cp ./utils/* .sh debian/
155- $(ENV_DOCKER ) buildx build --network=host --push \
156- -t $(ENV_APISIX_IMAGE_TAG_NAME ) -debian \
157- --platform linux/amd64,linux/arm64 \
158- -f ./debian/Dockerfile debian
159- rm -f debian/* .sh
160- @$(call func_echo_success_status, "$@ -> [ Done ]")
167+ $(call func_multiarch_build,debian,--push)
161168
169+ # ## build-multiarch-on-redhat : Build apache/apisix:xx-redhat multiarch image
170+ .PHONY : build-multiarch-on-redhat
171+ build-multiarch-on-redhat :
172+ $(call func_multiarch_build,redhat,)
162173
163174# ## push-multiarch-on-redhat : Push apache/apisix:xx-redhat image
164175.PHONY : push-multiarch-on-redhat
165176push-multiarch-on-redhat :
166- @$(call func_echo_status, "$@ -> [ Start ]")
167- $(ENV_DOCKER ) buildx build --network=host --push \
168- -t $(ENV_APISIX_IMAGE_TAG_NAME ) -redhat \
169- --platform linux/amd64,linux/arm64 \
170- -f ./redhat/Dockerfile redhat
171- @$(call func_echo_success_status, "$@ -> [ Done ]")
177+ $(call func_multiarch_build,redhat,--push)
172178
173179# ## push-multiarch-on-latest : Push apache/apisix:latest image
174180.PHONY : push-multiarch-on-latest
0 commit comments