Skip to content

Commit fcb8d3e

Browse files
committed
feat(python): add 3.10, 3.12, 3.13 images
1 parent 32c3bab commit fcb8d3e

File tree

4 files changed

+142
-1
lines changed

4 files changed

+142
-1
lines changed

.github/workflows/python.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ jobs:
4545
fail-fast: false
4646
matrix:
4747
python:
48-
- 3.11
4948
- '3'
49+
- 3.10
50+
- 3.11
51+
- 3.12
52+
- 3.13
5053

5154
steps:
5255
- uses: actions/checkout@v4

python/3.10/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Python image for AMP containers using Python 3.10 from upstream
2+
# ghcr.io/cubecoders/amp:python-3.10
3+
4+
FROM python:3.10-slim-bookworm AS py310
5+
6+
ENV DEBIAN_FRONTEND="noninteractive"
7+
8+
ARG PYTHON_VERSION="3.10"
9+
10+
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
11+
RUN chmod +x /usr/local/bin/find-deps.sh
12+
13+
RUN set -eux; \
14+
/usr/local/bin/find-deps.sh ${PYTHON_VERSION} >/tmp/${PYTHON_VERSION}-run-deps.txt
15+
16+
FROM ghcr.io/cubecoders/amp:debian
17+
LABEL org.opencontainers.image.licenses=MIT
18+
19+
ENV PIP_DISABLE_PIP_VERSION_CHECK="1"
20+
ENV DEBIAN_FRONTEND="noninteractive"
21+
22+
ARG PYTHON_VERSION="3.10"
23+
24+
# Drop in upstream Python 3.10
25+
COPY --from=py310 /usr/local/ /usr/local/
26+
27+
COPY --from=py310 /tmp/${PYTHON_VERSION}-run-deps.txt /tmp/${PYTHON_VERSION}-run-deps.txt
28+
29+
RUN set -eux; \
30+
apt-get update; \
31+
# Purge system Python binaries and libs
32+
PYTHON_PKGS="$(dpkg-query -W -f='${binary:Package}\n' \
33+
| awk '/^(python3($|[.:_-])|libpython3($|[.:_-]))/ {print}' \
34+
| sort -u)"; \
35+
printf '%s\n' "${PYTHON_PKGS}" | xargs -r apt-get purge --auto-remove -y; \
36+
\
37+
sort -u /tmp/${PYTHON_VERSION}-run-deps.txt \
38+
| awk 'NF && $1 !~ /^#/' \
39+
| xargs -r apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends; \
40+
apt-get clean; \
41+
rm -rf /var/lib/apt/lists/* /tmp/${PYTHON_VERSION}-run-deps.txt; \
42+
\
43+
python${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip setuptools wheel; \
44+
for shim in python python3 python${PYTHON_VERSION} pip pip3 pip${PYTHON_VERSION}; do \
45+
ln -sf "/usr/local/bin/${shim}" "/usr/bin/${shim}"; \
46+
done

python/3.12/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Python image for AMP containers using Python 3.12 from upstream
2+
# ghcr.io/cubecoders/amp:python-3.12
3+
4+
FROM python:3.12-slim-bookworm AS py312
5+
6+
ENV DEBIAN_FRONTEND="noninteractive"
7+
8+
ARG PYTHON_VERSION="3.12"
9+
10+
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
11+
RUN chmod +x /usr/local/bin/find-deps.sh
12+
13+
RUN set -eux; \
14+
/usr/local/bin/find-deps.sh ${PYTHON_VERSION} >/tmp/${PYTHON_VERSION}-run-deps.txt
15+
16+
FROM ghcr.io/cubecoders/amp:debian
17+
LABEL org.opencontainers.image.licenses=MIT
18+
19+
ENV PIP_DISABLE_PIP_VERSION_CHECK="1"
20+
ENV DEBIAN_FRONTEND="noninteractive"
21+
22+
ARG PYTHON_VERSION="3.12"
23+
24+
# Drop in upstream Python 3.12
25+
COPY --from=py312 /usr/local/ /usr/local/
26+
27+
COPY --from=py312 /tmp/${PYTHON_VERSION}-run-deps.txt /tmp/${PYTHON_VERSION}-run-deps.txt
28+
29+
RUN set -eux; \
30+
apt-get update; \
31+
# Purge system Python binaries and libs
32+
PYTHON_PKGS="$(dpkg-query -W -f='${binary:Package}\n' \
33+
| awk '/^(python3($|[.:_-])|libpython3($|[.:_-]))/ {print}' \
34+
| sort -u)"; \
35+
printf '%s\n' "${PYTHON_PKGS}" | xargs -r apt-get purge --auto-remove -y; \
36+
\
37+
sort -u /tmp/${PYTHON_VERSION}-run-deps.txt \
38+
| awk 'NF && $1 !~ /^#/' \
39+
| xargs -r apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends; \
40+
apt-get clean; \
41+
rm -rf /var/lib/apt/lists/* /tmp/${PYTHON_VERSION}-run-deps.txt; \
42+
\
43+
python${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip setuptools wheel; \
44+
for shim in python python3 python${PYTHON_VERSION} pip pip3 pip${PYTHON_VERSION}; do \
45+
ln -sf "/usr/local/bin/${shim}" "/usr/bin/${shim}"; \
46+
done

python/3.13/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Python image for AMP containers using Python 3.13 from upstream
2+
# ghcr.io/cubecoders/amp:python-3.13
3+
4+
FROM python:3.13-slim-bookworm AS py313
5+
6+
ENV DEBIAN_FRONTEND="noninteractive"
7+
8+
ARG PYTHON_VERSION="3.13"
9+
10+
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
11+
RUN chmod +x /usr/local/bin/find-deps.sh
12+
13+
RUN set -eux; \
14+
/usr/local/bin/find-deps.sh ${PYTHON_VERSION} >/tmp/${PYTHON_VERSION}-run-deps.txt
15+
16+
FROM ghcr.io/cubecoders/amp:debian
17+
LABEL org.opencontainers.image.licenses=MIT
18+
19+
ENV PIP_DISABLE_PIP_VERSION_CHECK="1"
20+
ENV DEBIAN_FRONTEND="noninteractive"
21+
22+
ARG PYTHON_VERSION="3.13"
23+
24+
# Drop in upstream Python 3.13
25+
COPY --from=py313 /usr/local/ /usr/local/
26+
27+
COPY --from=py313 /tmp/${PYTHON_VERSION}-run-deps.txt /tmp/${PYTHON_VERSION}-run-deps.txt
28+
29+
RUN set -eux; \
30+
apt-get update; \
31+
# Purge system Python binaries and libs
32+
PYTHON_PKGS="$(dpkg-query -W -f='${binary:Package}\n' \
33+
| awk '/^(python3($|[.:_-])|libpython3($|[.:_-]))/ {print}' \
34+
| sort -u)"; \
35+
printf '%s\n' "${PYTHON_PKGS}" | xargs -r apt-get purge --auto-remove -y; \
36+
\
37+
sort -u /tmp/${PYTHON_VERSION}-run-deps.txt \
38+
| awk 'NF && $1 !~ /^#/' \
39+
| xargs -r apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends; \
40+
apt-get clean; \
41+
rm -rf /var/lib/apt/lists/* /tmp/${PYTHON_VERSION}-run-deps.txt; \
42+
\
43+
python${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip setuptools wheel; \
44+
for shim in python python3 python${PYTHON_VERSION} pip pip3 pip${PYTHON_VERSION}; do \
45+
ln -sf "/usr/local/bin/${shim}" "/usr/bin/${shim}"; \
46+
done

0 commit comments

Comments
 (0)