feat: build multi-arch (amd64/arm64) images and publish both tags in a single buildx#745
Open
Yetkin Timocin (ytimocin) wants to merge 1 commit into
Open
Conversation
…a single buildx Make the hub-agent, member-agent, and refresh-token images multi-arch (linux/amd64 + linux/arm64) and collapse the publish path into a single dual-tag `docker buildx build`, removing the separate `imagetools create` retag step. - Makefile: add PLATFORMS / RELEASE_PLATFORMS; `push` now builds a multi-arch manifest. New `setup-qemu` target registers QEMU emulation for any multi-platform build regardless of whether the buildx builder already exists (the old recipe registered it only when creating the builder, so a pre-existing builder silently skipped emulation and the foreign-arch build failed with "exec format error"). IMAGE_EXTRA_TAG publishes the short alias within the same buildx push. - Dockerfiles: rely on BuildKit-provided TARGETOS/TARGETARCH for per-arch native builds (CGO + GOEXPERIMENT=systemcrypto links against the target arch's OpenSSL, so cross-compilation is not possible); add `# syntax=docker/dockerfile:1`, `COPY --link`, and package-path `go build` so a future second source file is not silently dropped. - release.yml: a single dual-tag `make push` replaces the imagetools retag (stable releases publish both vX.Y.Z and the short X.Y.Z; RC tags publish only the full form). The verify step now asserts each published tag is a real multi-arch manifest instead of only echoing tag strings. Part of kubefleet-dev#693 (Phase 1: add linux/arm64 to make push; replace the imagetools create retag with a single dual-tag buildx invocation). Signed-off-by: Yetkin Timocin <ytimocin@microsoft.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Make the
hub-agent,member-agent, andrefresh-tokenimages multi-arch (linux/amd64+linux/arm64) and collapse the image publish path into a single dual-tagdocker buildx build, removing the separatedocker buildx imagetools createretag step.Addresses two Phase 1 items from #693:
linux/arm64tomake push.imagetools createretag with a single dual-tagbuildxinvocation.Changes
Makefile
PLATFORMS(defaults to the host platform so local single-arch builds — e.g. loading into kind — keep working) andRELEASE_PLATFORMS(linux/amd64,linux/arm64);make pushnow builds a multi-arch manifest.setup-qemutarget registers QEMU emulation for any multi-platform build regardless of whether the buildx builder already exists. The previous recipe registered QEMU only inside the builder-creation branch, so on a runner where the builder already existed emulation was skipped and the foreign-arch build failed withexec format error. Single-platform builds skip QEMU (native, not needed).IMAGE_EXTRA_TAGadds an additional tag within the samebuildxinvocation, so a stable release publishes both the full and short tags from one build.Dockerfiles (
docker/*.Dockerfile)TARGETOS/TARGETARCHfor per-arch native builds.CGO_ENABLED=1+GOEXPERIMENT=systemcryptolinks against the target architecture's OpenSSL, so pure cross-compilation isn't possible — each arch is built natively under emulation.# syntax=docker/dockerfile:1andCOPY --link.go build(e.g../cmd/hubagent/) so a future second source file in a package isn't silently dropped.release.yml
make pushreplaces the oldmake push+imagetools createretag. Stable releases publish bothvX.Y.Zand the shortX.Y.Z; RC tags publish only the full form (the short-tag namespace stays reserved for stable releases consumers pin to).imagetools inspect) instead of only echoing tag strings.Testing
make push IMAGE_EXTRA_TAG=<v>forwards through the recursive make and emits two--tagflags per image; single-platform default emits one.refresh-tokento a local registry: onebuildxpush produced both tags at the same digest, each a manifest list containinglinux/amd64+linux/arm64; the verify-step logic passed.cmdmain packages compile via the package-path form.