Skip to content

Commit 35522ad

Browse files
committed
docker: Single-stage nogil base + cleanup
1 parent e537d6a commit 35522ad

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

docker/Dockerfile.amd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ARG FROM_IMAGE=ubuntu:22.04
1010
FROM $FROM_IMAGE AS ubuntu-base
1111
FROM rocm/dev-ubuntu-22.04:${ROCM_VERSION}-complete AS sdk-base
1212

13+
ENV DEBIAN_FRONTEND=noninteractive
14+
1315
COPY --from=ubuntu-base /opt /opt
1416
ENV PATH="/opt/python3/bin:${PATH}"
1517

@@ -19,13 +21,13 @@ ARG OMPI_BRANCH="v5.0.x"
1921
# Update and Install basic Linux development tools
2022
RUN rm /etc/apt/sources.list.d/* \
2123
&& apt-get update \
22-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
24+
&& apt-get install -y --no-install-recommends \
2325
dh-autoreconf git \
2426
ca-certificates ssh make libtinfo* initramfs-tools libelf-dev \
2527
wget build-essential autoconf automake libtool \
2628
pkg-config libnuma* gfortran flex hwloc cmake && \
2729
if [ ! -d "/opt/python3" ]; then \
28-
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
30+
apt-get install -y --no-install-recommends \
2931
python3-venv python3-dev python3-pip; \
3032
else \
3133
echo "Using free-threaded Python build"; \

docker/Dockerfile.devito

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ ARG GROUP_ID=1000
1616

1717
ENV PIP_USE_PEP517=1
1818

19-
# If we are using a free-threaded base image, need to install libffi-dev again
20-
ARG base
21-
RUN case "$base" in *nogil) \
22-
echo "Installing libffi-dev for free-threaded build"; \
23-
apt-get update && apt-get install -y libffi-dev;; \
24-
esac;
25-
2619
# Install pip dependencies
2720
RUN python3 -m venv /venv && \
2821
/venv/bin/pip install --no-cache-dir --upgrade pip wheel setuptools
2922
# Jupyter cannot yet be installed with a free-threaded Python build
30-
# See https://github.com/jupyterlab/jupyterlab/issues/16915#
23+
# See https://github.com/jupyterlab/jupyterlab/issues/16915
24+
ARG base
3125
RUN case "$base" in *nogil) \
3226
echo "Skipping jupyter installation for free-threaded build";; \
3327
*) \

docker/Dockerfile.nogil

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
ARG FROM_IMAGE=ubuntu:22.04
66

7-
# Builder stage: build Python 3.13 from source with the GIL disabled
87
FROM $FROM_IMAGE AS builder
98

10-
ARG DEBIAN_FRONTEND=noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
1110

1211
# Install build dependencies for Python
1312
RUN apt-get update && apt-get install -y \
@@ -18,22 +17,17 @@ RUN apt-get update && apt-get install -y \
1817
zlib1g-dev
1918

2019
# Clone CPython repository at the 3.13 branch
21-
RUN git clone --depth 1 --branch 3.13 https://github.com/python/cpython.git /usr/src/cpython
20+
RUN git clone --depth 1 --branch 3.13 https://github.com/python/cpython.git /tmp/cpython
2221

23-
WORKDIR /usr/src/cpython
22+
WORKDIR /tmp/cpython
2423

2524
# Configure, build, and install Python 3.13 with the GIL disabled
2625
RUN ./configure --prefix=/opt/python3 --disable-gil --enable-optimizations
2726
RUN make -j$(nproc)
2827
RUN make install
2928

30-
# Base runtime stage
31-
FROM $FROM_IMAGE
32-
33-
ARG DEBIAN_FRONTEND=noninteractive
34-
35-
# Copy Python build from the previous stage
36-
COPY --from=builder /opt/python3/ /opt/python3/
29+
# Clean up temp files
30+
RUN rm -rf /tmp/cpython
3731

3832
# Set the PATH to include custom Python build
3933
ENV PATH="/opt/python3/bin:${PATH}"

0 commit comments

Comments
 (0)