Repository navigation
Cross-compile the images instead of building arm64 under QEMU - #14
Merged
Merged
Conversation
The build stage had no --platform, so for linux/arm64 buildx ran the Go toolchain itself under QEMU: go mod download and go build emulated, three images in a row, 20-30 minutes per release and per image-check run. The binary is pure Go (CGO_ENABLED=0) and GOARCH already follows TARGETARCH, so run the build stage on the builder's platform and let Go cross-compile; the runtime stage only copies the binary.
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.
The build stage of the three Dockerfiles had no
--platform, so forlinux/arm64buildx ran the Go toolchain itself under QEMU --go mod downloadandgo buildemulated, three images in a row. The release took 20-30 minutes, and so did the arm64 leg ofimage-checkon every pull request (22 minutes on #13).The binary is pure Go (
CGO_ENABLED=0) andGOARCHalready followsTARGETARCH(#11), so the build stage now runs on the builder's own platform (FROM --platform=$BUILDPLATFORM) and Go cross-compiles. The runtime stage only copies the binary and runs nothing, so it needs no emulation either.Check:
image-checkon this PR builds all three images for both platforms and fails unless each binary's ELF machine matches its platform -- the same check that caught the amd64 binary in the arm64 image -- and its arm64 run time shows the speed-up.