Skip to content

Optimize multi-arch docker image build#838

Open
maxsxu wants to merge 1 commit intomasterfrom
max/optimize-multi-arch-docker-build
Open

Optimize multi-arch docker image build#838
maxsxu wants to merge 1 commit intomasterfrom
max/optimize-multi-arch-docker-build

Conversation

@maxsxu
Copy link
Copy Markdown
Member

@maxsxu maxsxu commented Mar 30, 2026

Motivation

Multi-arch builds (specifically arm64+amd64) using Docker Buildx are extremely slow when QEMU emulation is utilized for compiling code (like Go module downloading and compiling).
This PR optimizes the build by instructing Docker to use the native architecture of the build machine for the builder stage (--platform=$BUILDPLATFORM), while using Go's built-in cross-compilation features via TARGETOS and TARGETARCH. This significantly accelerates the build process.

Modifications

  • Added --platform=$BUILDPLATFORM to builder stages in Dockerfile and redhat.Dockerfile.
  • Overridden GOOS and GOARCH with $TARGETOS and $TARGETARCH in go build command.
  • Appended --platform=$TARGETPLATFORM to the base images on final stages to ensure the runtime container matches the target platform.
  • Fixed operator.Dockerfile to accept the platform parameter and select the right compiled artifact using TARGETARCH.
  • Updated the Makefile build targets to use docker buildx build for native multi-arch building (--platform linux/amd64,linux/arm64) using --load to mimic the previous docker build functionality where the image gets loaded to the local daemon (useful for the next targets or CI testing).

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Documentation

Need to update docs?

  • no-need-doc

    (No new features, just CI/Build system optimizations)

@maxsxu maxsxu requested review from a team, freeznet and nlu90 as code owners March 30, 2026 14:32
@github-actions github-actions bot added the no-need-doc This pr does not need any document label Mar 30, 2026
@maxsxu maxsxu force-pushed the max/optimize-multi-arch-docker-build branch from f7b4de2 to cf2f60d Compare March 30, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-need-doc This pr does not need any document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant