Skip to content

Commit 2326805

Browse files
committed
fix: add buildx context setup before starting build
Signed-off-by: bitliu <[email protected]>
1 parent a8f72f5 commit 2326805

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,21 @@ image.buildx.verify:
130130
docker buildx version; \
131131
fi
132132

133+
BUILDX_CONTEXT = gateway-api-builder
134+
BUILDX_PLATFORMS = linux/amd64,linux/arm64
135+
136+
# Setup multi-arch enviroment
137+
# Recreate a buildx context for multi-arch images.
138+
.PHONY: image.multiarch.setup
139+
image.multiarch.setup: image.buildx.verify
140+
@if [ "$(shell uname)" == "Linux" ]; then \
141+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes; \
142+
fi
143+
docker buildx rm $(BUILDX_CONTEXT) || :
144+
docker buildx create --use --name $(BUILDX_CONTEXT) --platform "${BUILDX_PLATFORMS}"
145+
133146
.PHONY: release-staging
134-
release-staging: image.buildx.verify
147+
release-staging: image.multiarch.setup
135148
hack/build-and-push.sh
136149

137150
# Generate a virtualenv install, which is useful for hacking on the

hack/build-and-push.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ then
6262
BINARY_TAG="${BASE_REF}"
6363
fi
6464

65+
# Support multi-arch image build and push.
66+
BUILDX_PLATFORMS="linux/amd64,linux/arm64"
67+
68+
echo "Building and pushing admission-server image...${BUILDX_PLATFORMS}"
69+
6570
# First, build the image, with the version info passed in.
6671
# Note that an image will *always* be built tagged with the GIT_TAG, so we know when it was built.
6772
# And, we add an extra version tag - either :latest or semver.
@@ -71,6 +76,6 @@ docker buildx build \
7176
-t ${REGISTRY}/admission-server:${VERSION_TAG} \
7277
--build-arg "COMMIT=${COMMIT}" \
7378
--build-arg "TAG=${BINARY_TAG}" \
74-
--platform linux/amd64,linux/arm64 \
79+
--platform ${BUILDX_PLATFORMS} \
7580
--push \
7681
.

0 commit comments

Comments
 (0)