add rust+cargo image (via home directory)

This commit is contained in:
Ben Potter 2021-09-09 23:44:58 -05:00
parent ecd9dc3d25
commit d1e540223f
No known key found for this signature in database
GPG Key ID: EB8C3CA53E63B1CB
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,30 @@
FROM codercom/enterprise-base:ubuntu
# Run everything as root
USER root
ARG DEBIAN_FRONTEND="noninteractive"
# Install rustup into /bin
ENV RUSTUP_HOME=/bin/rustup
# Temporarily install cargo in /tmp/cargo
ARG CARGO_HOME=/var/tmp/cargo
# Run the install script
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
# Select default Rust toolchain
RUN /var/tmp/cargo/bin/rustup default stable
# Add rust to PATH
ENV PATH=$PATH:$RUSTUP_HOME
# Set proper CARGO_HOME
ENV CARGO_HOME=/home/coder/.cargo
ENV PATH=$PATH:/home/coder/.cargo/bin
# Copy the configure script
# This will move cargo into the home directory
COPY configure /coder/configure
# Set back to coder user
USER coder

7
images/rust/configure vendored Executable file
View File

@ -0,0 +1,7 @@
# if /home/coder/.cargo/bin doesn't exist, move cargo from /tmp/cargo
if [ ! -d $CARGO_HOME ]; then
echo "Moving cargo from /var/tmp/cargo to $CARGO_HOME"
mkdir -p $CARGO_HOME
sudo mv -r /var/tmp/cargo/* $CARGO_HOME
fi