Skip to content

chore: speed up multi-arch Docker builds with cargo-zigbuild#52

Merged
mikkeldamsgaard merged 6 commits intomainfrom
worktree-cozy-foraging-matsumoto
Mar 14, 2026
Merged

chore: speed up multi-arch Docker builds with cargo-zigbuild#52
mikkeldamsgaard merged 6 commits intomainfrom
worktree-cozy-foraging-matsumoto

Conversation

@mikkeldamsgaard
Copy link
Contributor

Summary

  • Replace QEMU-emulated arm64 compilation (~44 min) with native cross-compilation using cargo-zigbuild + sccache, reducing release workflow from ~50 min to ~8-12 min
  • Switch mysql crate from native-tls (OpenSSL) to rustls-tls, eliminating ~60 transitive dependencies while keeping binary size at ~5 MB
  • Split release workflow into parallel testbuild (matrix amd64+arm64) → dockerpublish jobs; crates.io publish now runs after Docker images are pushed

Test plan

  • cargo test --all — 36 tests pass (unit + integration)
  • cargo clippy -- -D warnings — no warnings
  • cargo fmt --check — formatted
  • dprint check — formatted
  • make cross-build — produces correct static ELF binaries for both arches (file bin/initium-amd64 bin/initium-arm64)
  • Docker build + run for all 4 images (initium + jyq × amd64 + arm64) — --help works, jq/yq available in jyq variant
  • Push a test tag to verify full release workflow in CI

🤖 Generated with Claude Code

Replace QEMU-emulated arm64 compilation (~44 min) with native
cross-compilation using cargo-zigbuild + sccache. Split release
workflow into parallel test/build/docker/publish jobs.

- Switch mysql crate from native-tls (OpenSSL) to rustls-tls,
  removing the entire OpenSSL dependency tree (~60 crates)
- Replace multi-stage Rust Dockerfiles with minimal COPY-only images
- Add cross-build and docker-multiarch Makefile targets
- CI build job now cross-compiles both arches to warm sccache
- Remove bin/ from .dockerignore (needed by new Dockerfiles)
- Add Development section to README

Expected release time: ~8-12 min (was ~50 min).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 14, 2026 15:49
Add workflow_dispatch trigger with dry-run input (defaults to true).
In dry-run mode: Docker images are built but not pushed, cosign
signing is skipped, and crates.io publish is skipped. Enables
testing the full build pipeline without side effects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces QEMU-emulated multi-arch Docker builds with native cross-compilation using cargo-zigbuild and sccache, and switches the mysql crate from OpenSSL (native-tls) to rustls-tls to eliminate the OpenSSL dependency. The release and CI workflows are restructured into parallel jobs for faster execution.

Changes:

  • Dockerfiles simplified from multi-stage Rust builds to minimal images that COPY pre-built, cross-compiled binaries; Makefile gains cross-build and docker-multiarch targets
  • CI and release workflows split into parallel test/build jobs using cargo-zigbuild + sccache, with Docker and crates.io publish as downstream jobs
  • mysql crate switched to rustls-tls with minimal-rust and buffer-pool features, removing ~60 transitive dependencies (OpenSSL, native-tls, etc.)

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Dockerfile Replaced multi-stage Rust build with minimal alpine certs stage + scratch, copying pre-built arch-specific binary
Dockerfile.jyq Same simplification: alpine base with pre-built binary COPY using TARGETARCH
Makefile Added cross-build and docker-multiarch targets; build now creates bin/ dir
Cargo.toml Switched mysql crate to rustls-tls with minimal-rust and buffer-pool features
Cargo.lock Updated lock file reflecting dependency tree changes
.github/workflows/release.yml Split into test, build (matrix), docker, publish jobs with zigbuild + sccache
.github/workflows/ci.yml Build job now cross-compiles for both arches with zigbuild + sccache
.dockerignore Removed bin/ exclusion so Docker context includes pre-built binaries
README.md Added Development section with cross-compilation prerequisites
CHANGELOG.md Documented all workflow and build changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mikkeldamsgaard and others added 3 commits March 14, 2026 17:06
- actions/checkout v4 → v6
- actions/upload-artifact v4 → v7
- actions/download-artifact v4 → v8
- docker/build-push-action v6 → v7
- docker/setup-buildx-action v3 → v4
- docker/login-action v3 → v4
- sigstore/cosign-installer v3 → v4
- dprint/check v2.2 → v2.3

Node.js 20 will be deprecated June 2nd, 2026.
mozilla-actions/sccache-action v0.0.9 has no newer release yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace `cargo install cargo-zigbuild` (compiles from source, ~40s)
with `cargo binstall` (downloads pre-built binary, ~5s).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikkeldamsgaard
Copy link
Contributor Author

Addressing Copilot review: removed obsolete docker-build and docker-push Makefile targets (the new Dockerfile expects bin/initium-${TARGETARCH} from cross-build). Updated README to reference make docker-multiarch instead.

The new Dockerfile expects pre-built arch-specific binaries
(bin/initium-${TARGETARCH}), so plain `docker build` without
--platform no longer works. Use `make docker-multiarch` instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikkeldamsgaard mikkeldamsgaard merged commit cc8e8d7 into main Mar 14, 2026
8 checks passed
@mikkeldamsgaard mikkeldamsgaard deleted the worktree-cozy-foraging-matsumoto branch March 14, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants