rust-secure-code / cargo-sandbox

Perform Cargo builds inside of a sandboxed environment
Apache License 2.0
52 stars 1 forks source link

Podman/Docker ad-hoc sandbox #8

Open llebout opened 4 years ago

llebout commented 4 years ago

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.

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