diff --git a/docker/Dockerfile b/docker/Dockerfile index 6cdfd57f1b..4f69391258 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,6 +23,8 @@ # [conda_env_dev] -> [development] -> [development_pydbg] # \ # [build_docs] +# \ +# [git_clone] # # base: Contains all system packages common across all environments # conda_env: Create morpheus conda environment and set it as the new base @@ -38,6 +40,8 @@ # development_pydbg: Development + debug build of cpython and various GDB # debugging macros. # build_docs: Build the Morpheus documentation +# git_clone: Clone the Morpheus repository to ensure we do not unintentionally +# copy local build artifacts # ========================================================================= # # Args used in FROM commands must come first @@ -283,6 +287,21 @@ RUN --mount=type=bind,from=conda_bld_morpheus,source=/opt/conda/conda-bld,target /opt/conda/bin/conda env update --solver=libmamba -n morpheus --file \ conda/environments/runtime_cuda-${CUDA_MAJOR_VER}${CUDA_MINOR_VER}_arch-x86_64.yaml +# ============ Stage: git_clone ============ +# Perform a clone of the git repository this ensures that when we copy files from the source repository, we aren't +# unintentionally including build artifacts or other files that shouldn't be in the final image +FROM conda_env_dev as git_clone + +ARG MORPHEUS_ROOT_HOST + +# Source the morpheus env to pick up the git-lfs package +RUN --mount=type=bind,source=${MORPHEUS_ROOT_HOST},target=/opt/host_repo \ + source activate morpheus &&\ + git clone file:///opt/host_repo /tmp/morpheus_repo &&\ + cd /tmp/morpheus_repo &&\ + git lfs install &&\ + /tmp/morpheus_repo/scripts/fetch_data.py fetch datasets examples + # ============ Stage: runtime ============ # Setup container for runtime environment FROM runtime_conda_create as runtime @@ -290,14 +309,14 @@ FROM runtime_conda_create as runtime ARG MORPHEUS_ROOT_HOST # Only copy specific files/folders over that are necessary for runtime -COPY "${MORPHEUS_ROOT_HOST}/conda/environments/*.yaml" "./conda/environments/" -COPY "${MORPHEUS_ROOT_HOST}/docker" "./docker" +COPY --from=git_clone "/tmp/morpheus_repo/conda/environments/*.yaml" "./conda/environments/" +COPY --from=git_clone "/tmp/morpheus_repo/docker" "./docker" COPY --from=build_docs "/workspace/build/docs/html" "./docs" -COPY "${MORPHEUS_ROOT_HOST}/examples" "./examples" -COPY "${MORPHEUS_ROOT_HOST}/models/datasets" "./models/datasets" -COPY "${MORPHEUS_ROOT_HOST}/scripts" "./scripts" -COPY "${MORPHEUS_ROOT_HOST}/*.md" "./" -COPY "${MORPHEUS_ROOT_HOST}/LICENSE" "./" +COPY --from=git_clone "/tmp/morpheus_repo/examples" "./examples" +COPY --from=git_clone "/tmp/morpheus_repo/models/datasets" "./models/datasets" +COPY --from=git_clone "/tmp/morpheus_repo/scripts" "./scripts" +COPY --from=git_clone "/tmp/morpheus_repo/*.md" "./" +COPY --from=git_clone "/tmp/morpheus_repo/LICENSE" "./" RUN /opt/conda/bin/conda clean -afy && \ # Ensure the conda-bld directory is indexed even if empty diff --git a/docker/build_container_release.sh b/docker/build_container_release.sh index fc6a22c647..ee4028a89a 100755 --- a/docker/build_container_release.sh +++ b/docker/build_container_release.sh @@ -26,8 +26,5 @@ export DOCKER_TARGET=${DOCKER_TARGET:-"runtime"} popd &> /dev/null -# Fetch data -"${SCRIPT_DIR}/../scripts/fetch_data.py" fetch docs examples datasets - # Call the general build script ${SCRIPT_DIR}/build_container.sh