Skip to content

Instantly share code, notes, and snippets.

@p0tr3c
Created June 5, 2019 18:18
Show Gist options
  • Save p0tr3c/d0ad237550dd23bb98adc03ccb4a25d8 to your computer and use it in GitHub Desktop.
Save p0tr3c/d0ad237550dd23bb98adc03ccb4a25d8 to your computer and use it in GitHub Desktop.
Cargo source docker file
FROM rust:latest
ARG USER_UID="1000"
ARG GROUP_GID="1000"
ARG USER_NAME="rust"
ARG GROUP_NAME="rust"
ARG RUST_RELEASE_VERSION="0.36.0"
ARG RUST_RELEASE_URL="https://github.com/rust-lang/cargo/archive/${RUST_RELEASE_VERSION}.tar.gz"
RUN groupadd -r -g ${GROUP_GID} ${GROUP_NAME} && \
useradd -r -m -u ${USER_UID} -g ${GROUP_NAME} -G sudo -s /bin/bash ${USER_NAME}
RUN cd /opt && \
wget "$RUST_RELEASE_URL" && \
tar -zxvf "${RUST_RELEASE_VERSION}.tar.gz" && \
cd "/opt/cargo-${RUST_RELEASE_VERSION}" && \
cargo build --release && \
echo "PATH=/opt/cargo-${RUST_RELEASE_VERSION}/target/release:\$PATH" >> "/home/${USER_NAME}/.bashrc"
USER $USER_NAME
VOLUME /project
WORKDIR /project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment