Skip to content

Commit 3c62b54

Browse files
committed
Simplify pytorch Dockerfile.
1 parent 7cbe241 commit 3c62b54

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

ML-Frameworks/pytorch-aarch64/Dockerfile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@ COPY --chown=$DOCKER_USER:$DOCKER_USER welcome.txt /home/$DOCKER_USER/welcome.tx
3232

3333
# Switch to userland
3434
USER $DOCKER_USER
35-
RUN echo "DOCKER_USER=${DOCKER_USER}"
3635
WORKDIR /home/$DOCKER_USER
3736

38-
# Create virtual environment
39-
RUN python -m venv /home/$DOCKER_USER/.venv
40-
ENV PATH="/home/$DOCKER_USER/.venv/bin:${PATH}"
37+
# Add ~/.local/bin to PATH to use uv later
38+
ENV PATH="/home/$DOCKER_USER/.local/bin:${PATH}"
39+
40+
# Install uv for quicker package installations (installed to ~/.local/bin with --user)
41+
RUN python -m pip install --user uv==0.9.29
4142

42-
# Install uv for quicker package installations
43-
RUN pip install uv==0.9.29
43+
# Create virtual environment with uv
44+
RUN uv venv /home/$DOCKER_USER/.venv
45+
ENV PATH="/home/$DOCKER_USER/.venv/bin:${PATH}"
4446

45-
# Update to newer pip/setuptools/wheel (setuptools >= 70.0.0 due to CVE-2024-6345
46-
# and CVE-2025-47273, wheel >= 0.38.0 due to CVE-2022-40898) and delete old system
47-
# version (we essentially use apt:python3-pip to bootstrap pip)
48-
RUN uv pip install --upgrade pip~=25.2 setuptools~=78.1.1 wheel~=0.45.1
47+
# Remove pip and update to newer setuptools/wheel (setuptools >= 70.0.0 due to CVE-2024-6345
48+
# and CVE-2025-47273, wheel >= 0.38.0 due to CVE-2022-40898)
49+
RUN uv pip uninstall pip && uv pip install --upgrade setuptools~=78.1.1 wheel~=0.45.1
4950

5051
# Install non-torch requirements
5152
COPY --chown=$DOCKER_USER:$DOCKER_USER requirements.txt .
@@ -75,18 +76,17 @@ ENV DOCKER_USER=debian
7576

7677
# Runtime OS bits + UI
7778
RUN set -eux && \
78-
apt-get update && \
79-
rm -rf /var/lib/apt/lists/* && \
8079
if ! id "$DOCKER_USER" >/dev/null 2>&1; then useradd --create-home -s /bin/bash "$DOCKER_USER"; fi && \
8180
echo '[ -n "$TERM" -a -r "$HOME/welcome.txt" ] && cat "$HOME/welcome.txt"' >> /etc/bash.bashrc && \
82-
echo 'export PATH="$HOME/.local/bin:$HOME/.venv/bin:$PATH"' >> /etc/bash.bashrc
81+
echo 'export PATH="$HOME/.local/bin:$HOME/.venv/bin:$PATH"' >> /etc/bash.bashrc && \
82+
python3 -m pip uninstall -y pip
8383

8484
# Bring in prepped env + code
8585
COPY --from=workshop --chown=$DOCKER_USER:$DOCKER_USER /home/$DOCKER_USER /home/$DOCKER_USER
8686

8787
USER $DOCKER_USER
8888
WORKDIR /home/$DOCKER_USER
8989

90-
ENV PATH="/home/$DOCKER_USER/.venv/bin:${PATH}"
90+
ENV PATH="/home/$DOCKER_USER/.local/bin:/home/$DOCKER_USER/.venv/bin:$PATH"
9191

9292
CMD ["bash", "-l"]

ML-Frameworks/tensorflow-aarch64/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@ COPY --from=workshop --chown=$DOCKER_USER:$DOCKER_USER /home/$DOCKER_USER /home/
8484
USER $DOCKER_USER
8585
WORKDIR /home/$DOCKER_USER
8686

87+
ENV PATH="/home/$DOCKER_USER/.local/bin:/home/$DOCKER_USER/.venv/bin:$PATH"
88+
8789
CMD ["bash", "-l"]

0 commit comments

Comments
 (0)