Repository navigation
Build the arm64 image with an arm64 binary - #7
Merged
Merged
Conversation
The release workflow builds linux/amd64 and linux/arm64, but under QEMU an arm64 build succeeds even when the Dockerfile compiles for amd64, and the published arm64 image then cannot start. On pull requests, build every image for both platforms and compare the ELF machine of the binary inside with the platform. Nothing is pushed.
The Dockerfile hardcoded GOARCH=amd64, so the linux/arm64 image published by the multi-platform release build contained an amd64 binary and could not start on arm64 nodes. Take GOARCH from TARGETARCH, which buildx sets to the platform being built; a plain docker build leaves it empty and Go builds for the host as before.
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.
Problem
The published
linux/arm64image of4pdosc/hang-watchercontains an amd64 binary, so it cannot start on arm64 nodes. The Dockerfile hardcodeGOARCH=amd64; the release workflow builds arm64 under QEMU, where that build still succeeds.Checked on the registry by reading the ELF header of the entrypoint in each platform of the index (:0.1.27 and :latest): the arm64 entry is
x86-64.Change
GOARCHfromTARGETARCH, which buildx sets to the platform being built. A plaindocker buildleaves it empty and Go builds for the host, as before.image-checkworkflow on pull requests: builds every image forlinux/amd64andlinux/arm64and fails if the binary's ELF machine does not match the platform. Nothing is pushed.Testing
The check was pushed first on its own, against the unchanged Dockerfile, to confirm it fails on arm64; the fix follows in the next commit and the check passes. Once a release is cut, the published arm64 image should report
AArch64.