docs(development): describe the multi-arch default of make image - #711
Conversation
✅ Deploy Preview for cozystack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## What this PR does Package images can now be built for amd64 and arm64 in one `make image`, and a published build is multi-arch unless `PLATFORM` says otherwise. This is the build half of arm64 support from #1961 and #903. CI still publishes amd64 only until it gets a native arm64 leg, which comes in a separate PR. Builder stages now run on the build platform and compile for the target one, so Go never runs under emulation. Under emulation it is slow and it crashes: the migration-controller Dockerfile already records a "bad pointer in Go heap" from exactly that. On top of this, `PLATFORM` defaults to `linux/amd64,linux/arm64`. A build on an arm64 workstation can't publish an arm64-only digest any more. That happened once already, the cilium pin was arm64-only until 3f36a1b rebuilt it by hand. Two images were only right because they were emulated. On a native builder they would ship the wrong architecture. token-proxy ran `go build` with no GOARCH, and kube-ovn calls upstream `make build-go`, which hardcodes `GOARCH=amd64`. Both are fixed now. The new bats test wants every compiling stage on `$BUILDPLATFORM` and actually using `TARGETARCH`. A bare `ARG TARGETARCH` does not count, this is how token-proxy got through. Some things stay amd64. talos and testing pin it with `override`, because matchbox serves amd64 Talos assets and the sandbox runs `qemu-system-x86_64`. `LOAD=1` builds for the host only, since the classic docker image store can't load an index. Every CI build job pins `PLATFORM: linux/amd64`, so CI output does not change. This changes local builds. A `make image` on the default docker driver with the classic image store now fails with "Multi-platform build is not supported for the docker driver", where before it built for the host. Use a `docker-container` builder (`BUILDER=<name>`), or pass `PLATFORM=linux/amd64` (or `LOAD=1`) to build one architecture. I checked it on an arm64 host with a docker-container builder. cozystack-api, dashboard, kubeovn, platform-migrations, cilium and capi-providers-cpprovider build and push as amd64+arm64 indexes. Binaries pulled from each platform are x86-64 and aarch64: cozystack-api, token-proxy, the kamaji provider manager, cilium-agent and all four kube-ovn binaries. piraeus-server builds for both platforms, but the push to my test registry failed on registry 500s. The capi-providers-cpprovider inline cache works with a multi-platform push. Not covered is running the arm64 images on an arm64 cluster, CI has none. This is stacked on #4485 and targets its branch, so the diff here is only the two commits on top. ### Screenshots No UI changes. ### Downstream repositories - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#711 - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(build): package images build for linux/amd64 and linux/arm64 by default, with Go builders cross-compiling on the build platform; a local `make image` now needs a docker-container builder, or PLATFORM=linux/amd64 / LOAD=1 for a single architecture. CI still publishes amd64. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Build Improvements** * Container image builds now target both amd64 and arm64 by default when building without loading images locally. * CI and release builds are pinned to amd64; Talos and testing images remain amd64-only. * Cross-platform builds now compile on the builder’s native platform while targeting the requested architecture. * **Documentation** * Clarified platform defaults and architecture requirements for local and CI builds. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
IvanHunters
left a comment
There was a problem hiding this comment.
LGTM
Accurate docs change. I checked every claim against the merged source of cozystack/cozystack#4498: hack/common-envs.mk and the per-package Makefiles, not just the prose in docs/agents/overview.md.
- The multi-arch default comes from
common-envs.mk(DEFAULT_PLATFORMS := linux/amd64,linux/arm64, andPLATFORMdefaults to that unlessLOAD=1); the new bats test confirms a plain build passes--platform=linux/amd64,linux/arm64. - The single-arch override and the
LOAD=1behaviour match the test fixtures: an explicitPLATFORMreplaces the default, andLOAD=1passes no--platform. talosandtestingpinlinux/amd64viaoverride PLATFORM := linux/amd64in their Makefiles.- Scoping the change to
next/is right: #4498 landed on main only, and it is now merged, so the page no longer describes behaviour main lacks.
One non-blocking nit:
[NIT] content/en/docs/next/development.md:303: "so only package installs in the image run under emulation" understates the set. The source counts package installs, setcap, install scripts and patch steps as the target-platform RUN steps that run emulated. "only steps that run on the target platform" would cover it. The rest reads correctly.
ab409af to
305ee0e
Compare
cozystack now builds package images for linux/amd64 and linux/arm64 unless PLATFORM is set, which needs a builder that supports both. LOAD=1 builds for the host only, and talos and testing always build amd64. The development page showed a two-platform builder without saying why it is needed or how to build a single architecture. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
305ee0e to
b0cfd14
Compare
The development page should say that
make imagenow builds for linux/amd64 and linux/arm64 by default. That change is cozystack/cozystack#4498. The Buildx section already showed a builder with both platforms, but it never explained why. It also didn't say how to build a single architecture or whatLOAD=1does now.I only changed
next/, because released versions still build the old way. I'll keep this as a draft until the cozystack change is merged, so the page doesn't describe behaviour that main doesn't have yet.