@@ -31,6 +31,9 @@ FROM ${BASE_IMAGE} AS compile-image
31
31
ARG BASE_IMAGE=ubuntu:rolling
32
32
ARG PYTHON_VERSION
33
33
ARG BUILD_NIGHTLY
34
+ ARG BUILD_FROM_SRC
35
+ ARG LOCAL_CHANGES
36
+ ARG BRANCH_NAME
34
37
ENV PYTHONUNBUFFERED TRUE
35
38
36
39
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
@@ -64,18 +67,25 @@ RUN export USE_CUDA=1
64
67
65
68
ARG USE_CUDA_VERSION=""
66
69
67
- RUN git clone --depth 1 --recursive https://github.com/pytorch/serve.git
70
+ COPY ./ serve
71
+
72
+ RUN \
73
+ if echo "$LOCAL_CHANGES" | grep -q "false" ; then \
74
+ rm -rf serve;\
75
+ git clone --recursive https://github.com/pytorch/serve.git -b $BRANCH_NAME; \
76
+ fi
77
+
68
78
69
79
WORKDIR "serve"
70
80
71
81
RUN \
72
82
if echo "$BASE_IMAGE" | grep -q "cuda:" ; then \
73
83
# Install CUDA version specific binary when CUDA version is specified as a build arg
74
84
if [ "$USE_CUDA_VERSION" ]; then \
75
- python ./ts_scripts/install_dependencies.py --cuda $USE_CUDA_VERSION; \
85
+ python ./ts_scripts/install_dependencies.py --cuda $USE_CUDA_VERSION;\
76
86
# Install the binary with the latest CPU image on a CUDA base image
77
87
else \
78
- python ./ts_scripts/install_dependencies.py; \
88
+ python ./ts_scripts/install_dependencies.py;\
79
89
fi; \
80
90
# Install the CPU binary
81
91
else \
84
94
85
95
# Make sure latest version of torchserve is uploaded before running this
86
96
RUN \
87
- if echo "$BUILD_NIGHTLY" | grep -q "false" ; then \
97
+ if echo "$BUILD_FROM_SRC" | grep -q "true" ; then \
98
+ python -m pip install -r requirements/developer.txt;\
99
+ python ts_scripts/install_from_src.py;\
100
+ elif echo "$BUILD_NIGHTLY" | grep -q "false" ; then \
88
101
python -m pip install --no-cache-dir torchserve torch-model-archiver torch-workflow-archiver;\
89
102
else \
90
103
python -m pip install --no-cache-dir torchserve-nightly torch-model-archiver-nightly torch-workflow-archiver-nightly;\
@@ -121,12 +134,12 @@ COPY --chown=model-server --from=compile-image /home/venv /home/venv
121
134
122
135
ENV PATH="/home/venv/bin:$PATH"
123
136
124
- COPY dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh
137
+ COPY docker/ dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh
125
138
126
139
RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh \
127
140
&& chown -R model-server /home/model-server
128
141
129
- COPY config.properties /home/model-server/config.properties
142
+ COPY docker/ config.properties /home/model-server/config.properties
130
143
RUN mkdir /home/model-server/model-store && chown -R model-server /home/model-server/model-store
131
144
132
145
EXPOSE 8080 8081 8082 7070 7071
@@ -187,6 +200,8 @@ FROM ${BASE_IMAGE} as dev-image
187
200
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top)
188
201
ARG PYTHON_VERSION
189
202
ARG BRANCH_NAME
203
+ ARG BUILD_FROM_SRC
204
+ ARG LOCAL_CHANGES
190
205
ARG BUILD_WITH_IPEX
191
206
ARG IPEX_VERSION=1.11.0
192
207
ARG IPEX_URL=https://software.intel.com/ipex-whl-stable
@@ -216,9 +231,15 @@ RUN --mount=type=cache,target=/var/cache/apt \
216
231
numactl \
217
232
&& if [ "$BUILD_WITH_IPEX" = "true" ]; then apt-get update && apt-get install -y libjemalloc-dev libgoogle-perftools-dev libomp-dev && ln -s /usr/lib/x86_64-linux-gnu/libjemalloc.so /usr/lib/libjemalloc.so && ln -s /usr/lib/x86_64-linux-gnu/libtcmalloc.so /usr/lib/libtcmalloc.so && ln -s /usr/lib/x86_64-linux-gnu/libiomp5.so /usr/lib/libiomp5.so; fi \
218
233
&& rm -rf /var/lib/apt/lists/*
219
- RUN git clone --recursive https://github.com/pytorch/serve.git \
220
- && cd serve \
221
- && git checkout ${BRANCH_NAME}
234
+
235
+ COPY ./ serve
236
+
237
+ RUN \
238
+ if echo "$LOCAL_CHANGES" | grep -q "false" ; then \
239
+ rm -rf serve;\
240
+ git clone --recursive https://github.com/pytorch/serve.git -b $BRANCH_NAME; \
241
+ fi
242
+
222
243
COPY --from=compile-image /home/venv /home/venv
223
244
ENV PATH="/home/venv/bin:$PATH"
224
245
WORKDIR "serve"
@@ -238,4 +259,4 @@ USER model-server
238
259
WORKDIR /home/model-server
239
260
ENV TEMP=/home/model-server/tmp
240
261
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh" ]
241
- CMD ["serve" ]
262
+ CMD ["serve" ]
0 commit comments