Faster Rust builds!
cargo-green
: Cargo plugin and$RUSTC_WRAPPER
to sandbox, cache & remote execcargo
builds
- seamlessly build on another machine (with more cores, more cache)
- support remote builds by setting env
DOCKER_HOST=
with e.g.ssh://me@beaffy-machine.internal.net
- Build cache is saved remotely, artifacts are saved locally
- Tests building happens on remote machine, execution happens on local machine
- support remote builds by setting env
- seamlessly integrate with normal
cargo
usage- only pull sources from local filesystem
- produce the same intermediary artefacts as local
cargo
does - fallback to normal, local
rustc
anytime- switching from this wrapper back to local
rustc
does necessitate a fresh build
- switching from this wrapper back to local
- wrap
rustc
calls inbuildkit
-like calls (docker
,podman
)-
docker
-
podman
- deps compatibility
- handle Rust-only deps
- handle all the other deps (expand this list) (use
crater
)-
C
deps - ...
-
- runner compatibility
- set
.dockerignore
s (to be authoritative on srcs)
- set
- trace these outputs (STDOUT/STDERR) for debugging
-
- available as a
rustc
wrapper through$RUSTC_WRAPPER
- available as a
cargo
subcommand- configuration profiles (user, team, per-workspace, per-crate, CI, ...)
- seamlessly use current/local
rustc
version- support overriding
rustc
base image
- support overriding
- seamlessly use current/local tools (
mold
, ...)- config expressions on top of base image config?
- just suggest an inline
Dockerfile
stage?
- support CRUD-ish operations on local/remotes cache
-
[SEC]
support building a crate without it having network access
- integrate with shipping OCI images
- share cache with the World cf.
user-wide-cache
- never rebuild a dep (for a given version of
rustc
, ...) - share cache with other projects on local machine
- fix
WORKDIR
s + rewrite paths withremap-path-prefix
- fix
- share cache with CI and team
- share cache with CI (at least for a single user)
-
[SEC]
ensure private deps don't leak through/to cache - CLI gives the Dockerfile that
cargo install
's any crate
- never rebuild a dep (for a given version of
- suggest a global cache -faciliting configuration profile
- integrate with
cross
- build for a non-local target
-
rust
: Compile a crate from its source archive directly -
cargo
: Tellrustc
wrappers which envs to pass through to allow env sandboxing - TODO
- buildkit flags to prefix stdout and stderr progress
- buildkit flag to disable dockerignore and save disk read
- --ignore-file (closed) moby/moby#12886
- --no-ignore-file
- docker build support multiple input files
- --file-part
-
=1 stage per Dockerfile part file
- order doesn't matter: order is fixed when consolidation happens (internally)
- cargo + docker
- PoC originally written in Bash: https://github.com/fenollp/buildxargs/blob/buildx/tryin.sh
- Initial blog post https://fenollp.github.io/faster-rust-builds-docker_host
See ./hack/