Faster Rust builds!
cargo-green: Cargo plugin and$RUSTC_WRAPPERto sandbox, cache & remote execcargobuilds
- seamlessly build on another machine (with more cores, more cache)
- support remote builds by setting env
DOCKER_HOST=with e.g.ssh://[email protected]- 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
cargousage- only pull sources from local filesystem
- produce the same intermediary artefacts as local
cargodoes - fallback to normal, local
rustcanytime- switching from this wrapper back to local
rustcdoes necessitate a fresh build
- switching from this wrapper back to local
- wrap
rustccalls inbuildkit-like calls (docker,podman)-
docker -
podman - deps compatibility
- handle Rust-only deps
- handle all the other deps (expand this list) (use
crater)-
Cdeps - ...
-
- runner compatibility
- set
.dockerignores (to be authoritative on srcs)
- set
- trace these outputs (STDOUT/STDERR) for debugging
-
- available as a
rustcwrapper through$RUSTC_WRAPPER - available as a
cargosubcommand- configuration profiles (user, team, per-workspace, per-crate, CI, ...)
- seamlessly use current/local
rustcversion- support overriding
rustcbase image
- support overriding
- seamlessly use current/local tools (
mold, ...)- config expressions on top of base image config?
- just suggest an inline
Dockerfilestage?
- 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, ...)- ensure finest cache granularity (crate-level)
- free users from cache key built from
Cargo.lock(changes on every release cut!)
- share cache with other projects on local machine
- fix
WORKDIRs + 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
- run/test for a non-local target (with
cross's same caveats ie. QEMU)
-
rust: Compile a crate from its source archive directly -
cargo: Tellrustcwrappers which envs to pass through to allow env sandboxing -
buildkit:docker/dockerfileimage tags are late - gRPC buffers too small
-
buildkit: Build function: ResourceExhausted: grpc: received message larger than max (_ vs. 4194304) -
buildx:ResourceExhausted: grpc: received message larger than max (_ vs. 4194304) -
buildkit: remotedocker buildx buildwith large dockerfile givestrying to send message larger than max (22482550 vs. 16777216)error
-
-
buildkit: Support extractingADD --checksum=.. https://.. .. - TODO
- buildkit flag to disable dockerignore and save disk read
- --ignore-file (closed) Add support for specifying .dockerignore file with -i/--ignore
- --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
- Getting an image's digest fast, within a docker-container builder
- 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
# Usage: $0 #=> generate CI
#
# Usage: $0 ( <name@version> | <name> ) #=> cargo install name@version
# Usage: $0 ok #=> cargo install all working bins
#
# Usage: $0 ( build | test ) #=> cargo build ./cargo-green
#
# Usage: jobs=1 $0 .. #=> cargo --jobs=$jobs
# Usage: offline=1 $0 .. #=> cargo --frozen (defaults to just: --locked)
# Usage: rmrf=1 $0 .. #=> rm -rf $CARGO_TARGET_DIR/*; cargo ...
# Usage: reset=1 $0 .. #=> docker buildx rm $BUILDX_BUILDER; cargo ...
# Usage: clean=1 $0 .. #=> Both reset=1 + rmrf=1
# Usage: final=1 $0 .. #=> Generate final Containerfile
#
# Usage: DOCKER_HOST=.. $0 .. #=> Overrides machine
# Usage: BUILDX_BUILDER=.. $0 .. #=> Overrides builder (set to "empty" to set BUILDX_BUILDER='')Syncs ./recipes/*.Dockerfile files.
Verifies properties about caching crates & granularity.
docker buildx prune --all --force
Estimate of amount of crates reused through compilation of ./recipes/ --> ~5%!
Expecting more with larger/more representative corpus + smart locking of transitive deps.
recipes/[email protected]
8< 8< 8<
3: dep-l-utf8parse-0.2.1-522ff71b25340e24
5: dep-l-bitflags-1.3.2-70ce9f1f2fa253bc
5: dep-l-strsim-0.10.0-fd42a4ea370e31ec
5: dep-l-unicode-ident-1.0.12-4c1dc76c11b3deb8
6: dep-l-cfg-if-1.0.0-da34da6838abd7f1
Total recipes: 15
Total stages: 1065
Stages in common: 58
5.44%
all:
cargo +nightly fmt --all
./hack/clis.sh | tee .github/workflows/clis.yml
./hack/self.sh | tee .github/workflows/self.yml
CARGO_TARGET_DIR=$${CARGO_TARGET_DIR:-target/clippy} cargo clippy --locked --frozen --offline --all-targets --all-features -- --no-deps -W clippy::cast_lossless -W clippy::redundant_closure_for_method_calls -W clippy::str_to_string -W clippy::unnecessary_wraps
RUST_MIN_STACK=8000000 cargo nextest run --all-targets --all-features --locked --frozen --offline --no-fail-fast
git --no-pager diff --exit-code