RAS-1976: Fix cross-building Docker images - #67
Merged
Merged
Conversation
The final stage was pinned to --platform=$BUILDPLATFORM and go build never set GOARCH, so every pass built for amd64 and BuildKit labelled it arm64. Add ARG TARGETARCH + GOOS/GOARCH, unpin the final stage. Also swap the runtime image to alpine:3.24 (~250MB -> ~10MB), adding the ca-certificates and CGO_ENABLED=0 that golang:*-alpine gave us implicitly.
warrenbaileyons
approved these changes
Sep 28, 2026
warrenbaileyons
left a comment
Contributor
There was a problem hiding this comment.
This just needs the chart version updating
Contributor
|
/gcbrun |
Contributor
|
/gcbrun |
arroyoAle
approved these changes
Oct 1, 2026
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.
What and why?
On our amd64 CI builder,
go buildused the builder's architecture, so the arm64-targeted image contained an amd64 binary and failed with an "exec format error". An Apple Silicon builder could mask the issue for arm64 builds. AddTARGETOS/TARGETARCHand setGOOS/GOARCH, and unpin the final stage so the image and binary target the requested platform.This cross-compiles the Go build stage without emulating the Go compiler.
RUNcommands in the final target-platform stage may still require emulation on a non-native builder.Switch the runtime stage from the Go image to
alpine:3.24, installca-certificates, and build withCGO_ENABLED=0to keep the runtime image small and the binary static.How to test?
Check the binary's ELF architecture in the built root filesystem. The binary is at
opt/print-file/print-file. The arm64 check should printb7 00; repeat withlinux/amd64, which should print3e 00.Jira
https://officefornationalstatistics.atlassian.net/browse/RAS-1976