-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathDockerfile
126 lines (97 loc) · 3.99 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES.
# All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# syntax=docker/dockerfile:1.3
ARG BASE_IMG=nvcr.io/nvidia/cuda
ARG BASE_IMG_TAG=12.4.1-base-ubuntu22.04
# Use NVIDIA Morpheus as the base image
FROM $BASE_IMG:$BASE_IMG_TAG AS base
ARG RELEASE_TYPE="dev"
ARG VERSION=""
ARG VERSION_REV="0"
# Install necessary dependencies using apt-get
RUN apt-get update && apt-get install -y \
wget \
bzip2 \
ca-certificates \
curl \
libgl1-mesa-glx \
&& apt-get clean
RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" -O /tmp/miniforge.sh \
&& bash /tmp/miniforge.sh -b -p /opt/conda \
&& rm /tmp/miniforge.sh
# Add conda to the PATH
ENV PATH=/opt/conda/bin:$PATH
# Install Mamba, a faster alternative to conda, within the base environment
RUN --mount=type=cache,target=/opt/conda/pkgs \
--mount=type=cache,target=/root/.cache/pip \
conda install -y mamba conda-build==24.5.1 -n base -c conda-forge
COPY conda/environments/nv_ingest_environment.yml /workspace/nv_ingest_environment.yml
# Create nv_ingest base environment
RUN --mount=type=cache,target=/opt/conda/pkgs \
--mount=type=cache,target=/root/.cache/pip \
mamba env create -f /workspace/nv_ingest_environment.yml
# Set default shell to bash
SHELL ["/bin/bash", "-c"]
# Activate the environment (make it default for subsequent commands)
RUN echo "source activate nv_ingest_runtime" >> ~/.bashrc
# Install Tini via conda from the conda-forge channel
RUN --mount=type=cache,target=/opt/conda/pkgs \
--mount=type=cache,target=/root/.cache/pip \
source activate nv_ingest_runtime \
&& mamba install -y -c conda-forge tini
# Set the working directory in the container
WORKDIR /workspace
# Copy custom entrypoint script
COPY ./docker/scripts/entrypoint.sh /workspace/docker/entrypoint.sh
FROM base AS nv_ingest_install
# Copy the module code
COPY setup.py setup.py
COPY ci ci
# Prevent haystack from sending telemetry data
ENV HAYSTACK_TELEMETRY_ENABLED=False
# Ensure the NV_INGEST_VERSION is PEP 440 compatible
RUN if [ -z "${VERSION}" ]; then \
export VERSION="$(date +'%Y.%m.%d')"; \
fi; \
if [ "${RELEASE_TYPE}" = "dev" ]; then \
export NV_INGEST_VERSION_OVERRIDE="${VERSION}.dev${VERSION_REV}"; \
elif [ "${RELEASE_TYPE}" = "release" ]; then \
export NV_INGEST_VERSION_OVERRIDE="${VERSION}.post${VERSION_REV}"; \
else \
echo "Invalid RELEASE_TYPE: ${RELEASE_TYPE}"; \
exit 1; \
fi
ENV NV_INGEST_RELEASE_TYPE=${RELEASE_TYPE}
ENV NV_INGEST_VERSION_OVERRIDE=${NV_INGEST_VERSION_OVERRIDE}
ENV NV_INGEST_CLIENT_VERSION_OVERRIDE=${NV_INGEST_VERSION_OVERRIDE}
SHELL ["/bin/bash", "-c"]
COPY tests tests
COPY data data
COPY client client
COPY src/nv_ingest src/nv_ingest
RUN rm -rf ./src/nv_ingest/dist ./client/dist
# Add pip cache path to match conda's package cache
RUN --mount=type=cache,target=/opt/conda/pkgs \
--mount=type=cache,target=/root/.cache/pip \
chmod +x ./ci/scripts/build_pip_packages.sh \
&& ./ci/scripts/build_pip_packages.sh --type ${RELEASE_TYPE} --lib client \
&& ./ci/scripts/build_pip_packages.sh --type ${RELEASE_TYPE} --lib service
RUN --mount=type=cache,target=/opt/conda/pkgs\
--mount=type=cache,target=/root/.cache/pip \
source activate nv_ingest_runtime \
&& pip install ./dist/*.whl \
&& pip install ./client/dist/*.whl
RUN rm -rf src
FROM nv_ingest_install AS runtime
COPY src/microservice_entrypoint.py ./
COPY pyproject.toml ./
RUN chmod +x /workspace/docker/entrypoint.sh
# Set entrypoint to tini with a custom entrypoint script
ENTRYPOINT ["/opt/conda/envs/nv_ingest_runtime/bin/tini", "--", "/workspace/docker/entrypoint.sh"]
FROM nv_ingest_install AS development
RUN source activate nv_ingest_runtime && \
--mount=type=cache,target=/opt/conda/pkgs \
--mount=type=cache,target=/root/.cache/pip \
pip install -e ./client
CMD ["/bin/bash"]