Skip to content

Instantly share code, notes, and snippets.

@jyn514
Created December 2, 2019 21:55
Show Gist options
  • Select an option

  • Save jyn514/1feecb76d8267718c8b3437244cc5627 to your computer and use it in GitHub Desktop.

Select an option

Save jyn514/1feecb76d8267718c8b3437244cc5627 to your computer and use it in GitHub Desktop.
Shell script for building a rust crate using rustops/crates-build-env
#!/bin/sh
set -euv
#cargo check # make sure dependencies are installed
CONTAINER="$("docker" "create" \
"-v" "$(realpath ./target):/opt/rustwide/target:rw,Z" \
"-v" "$(realpath .):/opt/rustwide/workdir:ro,Z" \
"-v" ~/.cargo:/opt/rustwide/cargo-home:ro,Z \
"-v" ~/.rustup:/opt/rustwide/rustup-home:ro,Z \
"-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "MAP_USER_ID=$(id -u)" \
"-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "RUSTFLAGS=" \
"-e" 'RUSTDOCFLAGS=-Z unstable-options
--resource-suffix -20191116-1.41.0-nightly-5c5b8afd8
--static-root-path / --disable-per-crate-search
--extern-html-root-url bindgen=https://docs.rs/bindgen/0.52.0
--extern-html-root-url cmake=https://docs.rs/cmake/0.1.42' \
"-e" "CARGO_HOME=/opt/rustwide/cargo-home" \
"-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" \
"-w" "/opt/rustwide/workdir" "-m" "3221225472" "--network" "none" \
"rustops/crates-build-env" "/opt/rustwide/cargo-home/bin/cargo" \
"+nightly" "doc" --offline --locked "--lib" "--no-deps" "--target" "x86_64-unknown-linux-gnu")"
docker start -ai "$CONTAINER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment