Skip to content

Commit fb6777c

Browse files
chore: add multiarch build targets to catch build failures during CI
Previously, multiarch images were only built during releases (via push-multiarch-on-* targets), so build failures like the QEMU/ldconfig segfault were only discovered at release time. Add build-multiarch-on-* Makefile targets that build without pushing, and run them on PRs and master pushes. The push-multiarch-on-* targets now only run on release branches. Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
1 parent 37bf6d7 commit fb6777c

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

.github/workflows/apisix_push_docker_hub.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ jobs:
6767
username: ${{ secrets.DOCKERHUB_USER }}
6868
password: ${{ secrets.DOCKERHUB_TOKEN }}
6969

70-
- name: push apisix:latest image to docker hub
70+
- name: Build multiarch image
71+
if: ${{ !startsWith(github.ref_name, 'release/apisix') }}
72+
run: |
73+
make build-multiarch-on-${{ matrix.platform }}
74+
75+
- name: Push apisix:latest image to Docker Hub
7176
if: ${{ startsWith(github.ref_name, 'release/apisix') && (matrix.platform == 'ubuntu') }}
7277
run: |
7378
make push-multiarch-on-latest

Makefile

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
152166
push-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
165176
push-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

Comments
 (0)