Open
Conversation
f7b4de2 to
cf2f60d
Compare
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 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 viaTARGETOSandTARGETARCH. This significantly accelerates the build process.Modifications
--platform=$BUILDPLATFORMto builder stages inDockerfileandredhat.Dockerfile.GOOSandGOARCHwith$TARGETOSand$TARGETARCHingo buildcommand.--platform=$TARGETPLATFORMto the base images on final stages to ensure the runtime container matches the target platform.operator.Dockerfileto accept the platform parameter and select the right compiled artifact usingTARGETARCH.Makefilebuild targets to usedocker buildx buildfor native multi-arch building (--platform linux/amd64,linux/arm64) using--loadto mimic the previousdocker buildfunctionality where the image gets loaded to the local daemon (useful for the next targets or CI testing).Verifying this change
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)