Created
November 22, 2019 19:23
-
-
Save 0b10011/137a167bdb8ada1ecfdcd8b6aecf0e6d to your computer and use it in GitHub Desktop.
A dockerized drop-in replacement for `cargo` that supports caching.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a drop-in replacement for `cargo` | |
# that runs in a Docker container as the current user | |
# on the latest Rust image | |
# and saves all generated files to `./cargo/` and `./target/`. | |
# | |
# Be sure to make this file executable: `chmod +x ./cargo` | |
# | |
# # Examples | |
# | |
# - Running app: `./cargo run` | |
# - Building app: `./cargo build` | |
# - Building release: `./cargo build --release` | |
# | |
# # Installing globally | |
# | |
# To run `cargo` from anywhere, | |
# save this file to `/usr/local/bin`. | |
# You'll then be able to use `cargo` | |
# as if you had installed Rust globally. | |
sudo docker run \ | |
--rm \ | |
--user "$(id -u)":"$(id -g)" \ | |
--mount type=bind,src="$PWD",dst=/usr/src/app \ | |
--workdir /usr/src/app \ | |
--env CARGO_HOME=/usr/src/app/.cargo \ | |
rust:latest \ | |
cargo "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment