cargo-sandbox icon indicating copy to clipboard operation
cargo-sandbox copied to clipboard

Podman/Docker ad-hoc sandbox

Open llebout opened this issue 6 years ago • 0 comments

If that inspires anything:

$ cargo fetch && podman run --rm -it --mount type=bind,source="$(pwd)"/,target=/build,rw --mount type=bind,source="${HOME}"/.cargo/git,target=/usr/local/cargo/git,ro --mount type=bind,source="${HOME}"/.cargo/registry,target=/usr/local/cargo/registry,ro --network none -w /build rust cargo build --offline

Replace podman by sudo docker if you want docker. Replace rust with a suitable container image if your Rust project or any of its dependencies require additional dependencies.

  • Mounts $HOME/cargo/git and $HOME/cargo/registry as readonly for passing in source dependencies (only git and registry dependencies supported.)
  • Mounts the current directory as readwrite for passing in sources and passing out build artifacts

I could set this as an alias on my system to perform sandboxed builds.

llebout avatar Nov 26 '19 14:11 llebout