Skip to content

Commit

Permalink
Create the conda env as the morpheus user. This prevents the env file…
Browse files Browse the repository at this point in the history
…s from being owned by root
  • Loading branch information
dagardner-nv committed Dec 27, 2023
1 parent 4ebcbf5 commit 7afe21e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,39 @@ ARG PYTHON_VER=3.10
FROM ${FROM_IMAGE}:cuda11.8.0-ubuntu20.04-py3.10 AS base

ARG PROJ_NAME=mrc
ARG USERNAME=morpheus
ARG USER_UID=1000
ARG USER_GID=$USER_UID

SHELL ["/bin/bash", "-c"]

RUN --mount=type=cache,target=/var/cache/apt \
apt update &&\
apt install --no-install-recommends -y \
libnuma1 && \
libnuma1 \
sudo && \
rm -rf /var/lib/apt/lists/*

# create a user inside the container
RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \
usermod --shell /bin/bash $USERNAME && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME

COPY ./conda/environments/all_cuda-118_arch-x86_64.yaml /opt/mrc/conda/environments/all_cuda-118_arch-x86_64.yaml

RUN --mount=type=cache,target=/opt/conda/pkgs,sharing=locked \
echo "create env: ${PROJ_NAME}" && \
sudo -g conda -u $USERNAME \
CONDA_ALWAYS_YES=true \
/opt/conda/bin/mamba env create -q -n ${PROJ_NAME} --file /opt/mrc/conda/environments/all_cuda-118_arch-x86_64.yaml && \
chmod -R a+rwX /opt/conda && \
rm -rf /tmp/conda

RUN /opt/conda/bin/conda init --system &&\
sed -i 's/xterm-color)/xterm-color|*-256color)/g' ~/.bashrc &&\
echo "conda activate ${PROJ_NAME}" >> ~/.bashrc
echo "conda activate ${PROJ_NAME}" >> ~/.bashrc && \
cp /root/.bashrc /home/$USERNAME/.bashrc

# disable sscache wrappers around compilers
ENV CMAKE_CUDA_COMPILER_LAUNCHER=
Expand Down Expand Up @@ -76,7 +88,6 @@ RUN --mount=type=cache,target=/var/cache/apt \
less \
openssh-client \
psmisc \
sudo \
vim-tiny \
&& \
rm -rf /var/lib/apt/lists/*
Expand All @@ -91,17 +102,6 @@ RUN --mount=type=cache,target=/var/cache/apt \
apt-get install --no-install-recommends -y dotnet-sdk-6.0 &&\
rm -rf /var/lib/apt/lists/*

# create a user inside the container
ARG USERNAME=morpheus
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \
usermod --shell /bin/bash $USERNAME && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
cp /root/.bashrc /home/$USERNAME/.bashrc

USER $USERNAME

# default working directory
Expand Down

0 comments on commit 7afe21e

Please sign in to comment.