Skip to content

Commit

Permalink
Add ~/.cache/pip as a mounted cache, removes ~3GB of data from the image
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Dec 13, 2024
1 parent 0b6773a commit a150293
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ COPY . ./

RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locked \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# Install git-lfs before running the build to avoid errors during conda build
/opt/conda/bin/mamba install -y -n base -c conda-forge "git-lfs" &&\
source activate base &&\
Expand Down Expand Up @@ -227,6 +228,7 @@ COPY ${MORPHEUS_ROOT_HOST}/conda/environments/dev_cuda-${CUDA_MAJOR_VER}${CUDA_M

# Update the morpheus environment
RUN --mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# Temp add channel_alias to get around conda 404 errors
conda config --env --set channel_alias ${CONDA_CHANNEL_ALIAS} &&\
/opt/conda/bin/conda env update --solver=libmamba -n morpheus --file conda/environments/dev.yaml &&\
Expand Down Expand Up @@ -263,6 +265,7 @@ COPY . ./

RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locked \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# Install git-lfs before running the build to avoid errors during conda build
/opt/conda/bin/mamba install -y -n base -c conda-forge "git-lfs" &&\
source activate base &&\
Expand All @@ -285,6 +288,7 @@ COPY . ./
RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locked \
--mount=type=bind,from=conda_bld_morpheus,source=/opt/conda/conda-bld,target=/opt/conda/conda-bld \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
source activate morpheus &&\
CONDA_ALWAYS_YES=true /opt/conda/bin/mamba install -n morpheus \
-c local \
Expand Down Expand Up @@ -314,6 +318,7 @@ COPY "${MORPHEUS_ROOT_HOST}/conda/environments/runtime_cuda-${CUDA_MAJOR_VER}${C
# Mount Morpheus conda package build in `conda_bld_morpheus`
RUN --mount=type=bind,from=conda_bld_morpheus,source=/opt/conda/conda-bld,target=/opt/conda/conda-bld \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# CVE-2018-20225 for the base pip, not the env one
# conda will ignore the request to remove pip
python -m pip uninstall -y pip && \
Expand Down

0 comments on commit a150293

Please sign in to comment.