| Crates.io | cargo-green |
| lib.rs | cargo-green |
| version | 0.18.0 |
| created_at | 2024-05-11 10:27:16.385342+00 |
| updated_at | 2025-09-07 21:37:37.93051+00 |
| description | Cargo plugin and $RUSTC_WRAPPER to sandbox & cache cargo builds and execute jobs remotely |
| homepage | |
| repository | https://github.com/fenollp/supergreen |
| max_upload_size | |
| id | 1236783 |
| size | 357,034 |
cargo-greenCached & remote-ready Rust projects builder by forwarding rustc calls to BuildKit builders.
cargo-green is
a cargo plugin that sets a $RUSTC_WRAPPER then calls cargo.
a RUSTC_WRAPPER that builds Dockerfiles
Reads envs (show values with cargo green supergreen env)
$CARGOGREEN_ADD_APK: add.apk TOML setting$CARGOGREEN_ADD_APT_GET: add.apt-get TOML setting$CARGOGREEN_ADD_APT: add.apt TOML setting$CARGOGREEN_BASE_IMAGE_INLINE: base-image-inline TOML setting$CARGOGREEN_BASE_IMAGE: base-image TOML setting$CARGOGREEN_BUILDER_IMAGE: image to use when creating builder container$CARGOGREEN_CACHE_IMAGES: cache-images TOML setting$CARGOGREEN_FINAL_PATH: if set, this file will end up with the final Dockerfile that reproduces the build$CARGOGREEN_INCREMENTAL: incremental TOML setting$CARGOGREEN_LOG_PATH: logfile path$CARGOGREEN_LOG_STYLE$CARGOGREEN_LOG: equivalent to $RUST_LOG (and doesn't conflict with cargo's)$CARGOGREEN_REMOTE: reserved for now$CARGOGREEN_RUNNER: use docker or podman or none as build runner$CARGOGREEN_SET_ENVS: set-envs TOML setting$CARGOGREEN_SYNTAX: use a dockerfile:1-derived BuildKit frontend$CARGOGREEN_WITH_NETWORK: with-network TOML settingAlso passes these envs through to the runner:
BUILDKIT_PROGRESS$BUILDX_BUILDERDOCKER_API_VERSIONDOCKER_CERT_PATHDOCKER_CONFIGDOCKER_CONTENT_TRUST_SERVERDOCKER_CONTENT_TRUSTDOCKER_CONTEXTDOCKER_DEFAULT_PLATFORMDOCKER_HIDE_LEGACY_COMMANDS$DOCKER_HOSTDOCKER_TLS_VERIFYDOCKER_TLSHTTP_PROXYHTTPS_PROXYNO_PROXYSets
$CARGOGREEN=1
docker or podman client is installedUbuntu 22.04 with github.com/docker/buildx v0.11.2 9872040 and rust 1.73cargo green add
cargo green bench
cargo green build
cargo green check
cargo green clean
cargo green clippy
cargo green doc
cargo green init
cargo green install
cargo green new
cargo green package
cargo green publish
cargo green remove
cargo green run
cargo green search
cargo green test
cargo green uninstall
cargo green update
# or, setting an alias in e.g. ~/.bashrc
alias cargo='cargo green'
# With this, one may also use this set of subcommands: [UNSTABLE API] (refacto into a `cache` cmd)
cargo supergreen config get VAR*
cargo supergreen config set VAR VAL
cargo supergreen config unset VAR
cargo supergreen pull-images Pulls latest versions of images used for the build, no cache (respects $DOCKER_HOST)
cargo supergreen pull-cache Pulls all from `--cache-from`
cargo supergreen push-cache Pushes all to `--cache-to`
cargo-green@0.6.0: Cargo plugin and $RUSTC_WRAPPER to sandbox & cache cargo builds and execute jobs remotely
https://github.com/fenollp/supergreen
Usage:
cargo green supergreen env Show used values
cargo green fetch Pulls images (respects $DOCKER_HOST)
cargo green supergreen push Push cache image (all tags)
cargo green supergreen -h | --help
cargo green supergreen -V | --version
Say you have a bigger machine in your ~/.ssh/config called extra_oomph:
export DOCKER_HOST=ssh://extra_oomph
cargo green test ...
# Installs to ~/.cargo/bin
cargo install --locked --force --git https://github.com/fenollp/supergreen.git cargo-green
# Make sur $CARGO_HOME/bin is in your $PATH
which cargo-green
In no particular order:
crane: A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
=> Very complete! Relies on nix tools and language.sccache: sccache - Shared Compilation Cache
=> Relies on everyone having the same paths and doesn't cache all crate types.cargo-chef: A cargo-subcommand to speed up Rust Docker builds using Docker layer caching.
=> Relies on everyone having the same paths + cache isn't crate-granular.rules_rust: Rules Rust
=> Replaces cargo with bazel.cargo-remote: cargo subcommand to compile rust projects remotely
=> Uses rsync and ssh; seems unmaintained.rust-cache: A GitHub Action that implements smart caching for rust/cargo projects
=> A GitHub Action.cargo-cross: “Zero setup” cross compilation and “cross testing” of Rust crates
=> seldomly maintained but a lifesaver for cross compilation.
See also this article on what cargo-green does (perfect layering):Proposal: c8d: expose contentstore API #44369 https://github.com/moby/moby/issues/44369
Incremental export transfer #1224 https://github.com/moby/buildkit/issues/1224
"sending tarball" takes a long time even when the image already exists #107 https://github.com/docker/buildx/issues/107
Build drivers https://docs.docker.com/build/drivers/
https://docs.docker.com/build/ci/github-actions/configure-builder/#max-parallelism
https://docs.docker.com/engine/reference/builder/#buildkit-built-in-build-args
tunnel tty into a docker build through http
docker build remote driver https://docs.docker.com/build/drivers/remote
rootless k8s driver https://docs.docker.com/build/drivers/kubernetes/#rootless-mode
tune many options https://docs.docker.com/build/drivers/docker-container/
https://docs.docker.com/build/attestations/sbom/
BUILDKIT_SBOM_SCAN_CONTEXT and BUILDKIT_SBOM_SCAN_STAGEprune: filtering out ADD --checksum=... https://... entries #2448
-o=.: open $HOME/.local/share/docker/overlay2/066f6../work/work: permission denied #2219
cargo restrict targets of crate
Target configuration for binaries #9208 https://github.com/rust-lang/cargo/issues/9208
Unsafe fields #3458 https://github.com/rust-lang/rfcs/pull/3458
Warning when large binary files are included into the bundle #9058 https://github.com/rust-lang/cargo/issues/9058
Hermetic build mode #9506 https://github.com/rust-lang/cargo/issues/9506
Feature Request static asserts #2790 https://github.com/rust-lang/rfcs/issues/2790
greater supply chain attack risk due to large dependency trees? https://www.reddit.com/r/rust/comments/102yz60/greater_supply_chain_attack_risk_due_to_large/
https://doc.rust-lang.org/rustc/command-line-arguments.html#option-emit
[build] rustflags = ["--remap-path-prefix"
/r/Rust scare Serde has started shipping precompiled binaries with no way to opt out
What's the best practice for caching compilation of Rust dependencies?