Skip to content

Commit 4d02c39

Browse files
committed
remove duplicate python installation
Signed-off-by: bin <[email protected]>
1 parent 4393684 commit 4d02c39

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

docker/Dockerfile

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,20 +280,33 @@ ARG GDRCOPY_OS_VERSION=Ubuntu22_04
280280

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

283+
COPY --from=base /opt/venv /opt/venv
284+
COPY --from=base /root/.local /root/.local
285+
286+
ENV PATH="/opt/venv/bin:/root/.local/bin:$PATH"
287+
ENV VIRTUAL_ENV="/opt/venv"
288+
ENV UV_HTTP_TIMEOUT=500
289+
ENV UV_INDEX_STRATEGY="unsafe-best-match"
290+
ENV UV_LINK_MODE=copy
291+
RUN rm -f /usr/bin/python3 /usr/bin/python3-config /usr/bin/pip \
292+
&& ln -sf /opt/venv/bin/python3 /usr/bin/python3 \
293+
&& ln -sf /opt/venv/bin/python3-config /usr/bin/python3-config \
294+
&& ln -sf /opt/venv/bin/pip /usr/bin/pip
295+
283296
ARG DEADSNAKES_MIRROR_URL
284297
ARG DEADSNAKES_GPGKEY_URL
285298
ARG GET_PIP_URL
286299

287300
RUN PYTHON_VERSION_STR=$(echo ${PYTHON_VERSION} | sed 's/\.//g') && \
288301
echo "export PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> /etc/environment
289302

290-
# Install Python and other dependencies
291303
RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
292304
&& echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
293305
&& apt-get update -y \
294306
&& apt-get install -y ccache software-properties-common git curl wget sudo vim python3-pip \
295-
&& apt-get install -y ffmpeg libsm6 libxext6 libgl1 \
296-
&& if [ ! -z ${DEADSNAKES_MIRROR_URL} ] ; then \
307+
&& apt-get install -y ffmpeg libsm6 libxext6 libgl1
308+
309+
RUN if [ ! -z ${DEADSNAKES_MIRROR_URL} ] ; then \
297310
if [ ! -z "${DEADSNAKES_GPGKEY_URL}" ] ; then \
298311
mkdir -p -m 0755 /etc/apt/keyrings ; \
299312
curl -L ${DEADSNAKES_GPGKEY_URL} | gpg --dearmor > /etc/apt/keyrings/deadsnakes.gpg ; \
@@ -307,10 +320,7 @@ RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
307320
done ; \
308321
fi \
309322
&& apt-get update -y \
310-
&& apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv libibverbs-dev \
311-
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
312-
&& update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION} \
313-
&& ln -sf /usr/bin/python${PYTHON_VERSION}-config /usr/bin/python3-config \
323+
&& apt-get install -y libibverbs-dev python${PYTHON_VERSION}-dev \
314324
&& curl -sS ${GET_PIP_URL} | python${PYTHON_VERSION} \
315325
&& python3 --version && python3 -m pip --version
316326

@@ -320,10 +330,6 @@ ARG PYTORCH_CUDA_INDEX_BASE_URL
320330
ARG PYTORCH_CUDA_NIGHTLY_INDEX_BASE_URL
321331
ARG PIP_KEYRING_PROVIDER UV_KEYRING_PROVIDER
322332

323-
# Install uv for faster pip installs
324-
RUN --mount=type=cache,target=/root/.cache/uv \
325-
python3 -m pip install uv
326-
327333
# This timeout (in seconds) is necessary when installing some dependencies via uv since it's likely to time out
328334
# Reference: https://github.com/astral-sh/uv/pull/1694
329335
ENV UV_HTTP_TIMEOUT=500

0 commit comments

Comments
 (0)