Move compilation for container images outside of Docker
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 70
- Forks
- 16
- Avg merge
- 4h 36m
- Merged PRs (30d)
- 30
Description
We may be able to improve build cache granularity if we move rustc compilation out of Docker, and instead cross-compile on the host, then copy the resulting binary into an image layer. This is what Prometheus does with Go builds, via promu, and similar to how rules_oci for Bazel works. We would have to install support for an additional target via rustup, and invoke cargo build with --target x86_64-unknown-linux-musl (or just --target x86_64-unknown-linux-gnu if we switch to distroless, see divviup/janus-ops#742). Currently, with the cargo-bake approach, any change to Cargo.toml requires a full rebuild. With this approach, we would be able to reuse most .rlibs in that situation. There's also potential to reduce duplication of target directories between the Dockerfile images and the Dockerfile.interop/Dockerfile.interop_aggregator images. Note that this would also make building images for other architectures easier (#948), since neither ARM build hosts nor emulation would be required.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current cargo-bake flow and the Dockerfile, Dockerfile.interop, and Dockerfile.interop_aggregator images. Check how rustup targets and cargo build currently run, then assess host cross-compilation and copying the resulting binary into image layers. Done means the images build with reusable Rust artifacts while retaining the interop image behavior and enabling other architectures without emulation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, rust
- Domain
- build-system, devops
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100