Open
Conversation
cf2f60d to
f6821d9
Compare
f6821d9 to
1d77fa4
Compare
There was a problem hiding this comment.
Pull request overview
This PR speeds up multi-architecture (amd64+arm64) Docker builds by ensuring Go compilation happens on the native builder architecture (BUILDPLATFORM) while cross-compiling the resulting binaries for the target architecture (TARGETOS/TARGETARCH), and by updating build scripts/targets to support multi-platform Buildx builds.
Changes:
- Update Dockerfiles to use
FROM --platform=$BUILDPLATFORMfor builder stages and cross-compile withGOOS=$TARGETOS/GOARCH=$TARGETARCH. - Update
Makefileandimages/**/build.shscripts to accept aPLATFORMSlist and usedocker buildx buildfor multi-platform builds. - Adjust pulsarctl runner images to download the correct
pulsarctlartifact foramd64vsarm64, and update release workflow to set up Buildx and build multi-platform images.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
Dockerfile |
Use native builder platform + Go cross-compilation for faster multi-arch builds. |
redhat.Dockerfile |
Same optimization for Red Hat certification image build. |
operator.Dockerfile |
Build operator binary inside Docker build (builder stage) and copy into runtime image. |
Makefile |
Add PLATFORMS support and switch to Buildx + push for multi-platform builds. |
README.md |
Document PLATFORMS usage for multi-platform image builds. |
images/build.sh |
Add PLATFORMS + multi-platform Buildx flow for runner images; enforce push requirements. |
images/samples/build.sh |
Add PLATFORMS + multi-platform Buildx flow for sample images; enforce push requirements. |
images/samples/go-function-samples/Dockerfile |
Use native builder platform + Go cross-compilation for sample image. |
images/pulsar-functions-base-runner/pulsarctl.Dockerfile |
Download arch-specific pulsarctl based on TARGETARCH. |
images/pulsar-functions-python-runner/pulsarctl.Dockerfile |
Download arch-specific pulsarctl based on TARGETARCH. |
images/pulsar-functions-java-runner/pulsarctl.Dockerfile |
Parameterize base image via BASE_IMAGE build arg. |
images/pulsar-functions-go-runner/pulsarctl.Dockerfile |
Parameterize base image via BASE_IMAGE build arg. |
.github/workflows/release.yml |
Set up Buildx and build/publish multi-platform images in release workflow. |
docs/release_proocess.md |
Note that release workflow publishes amd64+arm64 images. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Multi-arch builds (specifically arm64+amd64) using Docker Buildx are extremely slow when QEMU emulation is used for Go module download and compilation.
This PR optimizes the build by instructing Docker to use the native architecture of the build machine for builder stages (
--platform=$BUILDPLATFORM), while using Go's built-in cross-compilation viaTARGETOSandTARGETARCHfor the produced binaries.Modifications
--platform=$BUILDPLATFORMto builder stages inDockerfile,redhat.Dockerfile,operator.Dockerfile, and the sample Go function Dockerfile.TARGETOSandTARGETARCHinside Docker builds.Makefileandimages/**/build.shto accept aPLATFORMSlist.docker build, and useddocker buildx build --pushfor multi-platform builds so manifest-list images can be published directly.pulsarctlartifact foramd64andarm64.linux/amd64andlinux/arm64images.Verifying this change
bash -n images/build.shbash -n images/samples/build.shmake -n docker-build PLATFORMS=linux/amd64,linux/arm64make -n operator-docker-image PLATFORMS=linux/arm64docker build --platform linux/arm64 -f operator.Dockerfile -t function-mesh-verify:arm64 .docker buildx build --platform linux/amd64,linux/arm64 --output=type=cacheonly -f operator.Dockerfile .make docker-build-skip-test PLATFORMS=linux/arm64 IMG=function-mesh-verify:makeDocumentation