Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
144 lines (98 loc) · 5.12 KB
/
Copy pathDockerfile
File metadata and controls
144 lines (98 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Python image for AMP containers including Python 3.10, 3.11, 3.12, 3.13 (default), 3.14 and 3.15 from upstream
# cubecoders/ampbase:python-3
FROM python:3.10-slim-trixie AS py310
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_VERSION="3.10"
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
RUN chmod +x /usr/local/bin/find-deps.sh
RUN set -eux; \
/usr/local/bin/find-deps.sh >/tmp/${PYTHON_VERSION}-run-deps.txt
FROM python:3.11-slim-trixie AS py311
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_VERSION="3.11"
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
RUN chmod +x /usr/local/bin/find-deps.sh
RUN set -eux; \
/usr/local/bin/find-deps.sh >/tmp/${PYTHON_VERSION}-run-deps.txt
FROM python:3.12-slim-trixie AS py312
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_VERSION="3.12"
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
RUN chmod +x /usr/local/bin/find-deps.sh
RUN set -eux; \
/usr/local/bin/find-deps.sh >/tmp/${PYTHON_VERSION}-run-deps.txt
FROM python:3.14-slim-trixie AS py314
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_VERSION="3.14"
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
RUN chmod +x /usr/local/bin/find-deps.sh
RUN set -eux; \
/usr/local/bin/find-deps.sh >/tmp/${PYTHON_VERSION}-run-deps.txt
FROM python:3.15-slim-trixie AS py315
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_VERSION="3.15"
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
RUN chmod +x /usr/local/bin/find-deps.sh
RUN set -eux; \
/usr/local/bin/find-deps.sh >/tmp/${PYTHON_VERSION}-run-deps.txt
FROM python:3.13-slim-trixie AS py313
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_VERSION="3.13"
COPY scripts/python/find-deps.sh /usr/local/bin/find-deps.sh
RUN chmod +x /usr/local/bin/find-deps.sh
RUN set -eux; \
/usr/local/bin/find-deps.sh >/tmp/${PYTHON_VERSION}-run-deps.txt
FROM cubecoders/ampbase:debian
LABEL org.opencontainers.image.licenses=MIT
ENV PIP_DISABLE_PIP_VERSION_CHECK="1"
ENV AMP_ADDITIONAL_ENV_VARS="PIP_DISABLE_PIP_VERSION_CHECK"
ENV DEBIAN_FRONTEND="noninteractive"
ARG PYTHON_DEFAULT="3.13"
ARG PYTHON_NON_DEFAULT="3.10 3.11 3.12 3.14 3.15"
# Drop in upstream Python 3.10
COPY --from=py310 /usr/local/ /usr/local/
COPY --from=py310 /tmp/3.10-run-deps.txt /tmp/3.10-run-deps.txt
# Drop in upstream Python 3.11
COPY --from=py311 /usr/local/ /usr/local/
COPY --from=py311 /tmp/3.11-run-deps.txt /tmp/3.11-run-deps.txt
# Drop in upstream Python 3.12
COPY --from=py312 /usr/local/ /usr/local/
COPY --from=py312 /tmp/3.12-run-deps.txt /tmp/3.12-run-deps.txt
# Drop in upstream Python 3.14
COPY --from=py314 /usr/local/ /usr/local/
COPY --from=py314 /tmp/3.14-run-deps.txt /tmp/3.14-run-deps.txt
# Drop in upstream Python 3.15
COPY --from=py315 /usr/local/ /usr/local/
COPY --from=py315 /tmp/3.15-run-deps.txt /tmp/3.15-run-deps.txt
# Drop in upstream Python 3.13 (default last)
COPY --from=py313 /usr/local/ /usr/local/
COPY --from=py313 /tmp/3.13-run-deps.txt /tmp/3.13-run-deps.txt
RUN set -eux; \
apt-get update; \
# Purge system Python binaries and libs
PYTHON_PKGS="$(dpkg-query -W -f='${binary:Package}\n' \
| awk '/^(python3($|[.:_-])|libpython3($|[.:_-]))/ {print}' \
| sort -u)"; \
printf '%s\n' "${PYTHON_PKGS}" | xargs -r apt-get purge --auto-remove -y; \
\
# Don't reinstall gdb: its libpython3.13 dep restores /usr/lib/python3.13, which breaks venvs made via /usr/bin/python3
sort -u /tmp/*-run-deps.txt \
| awk 'NF && $1 !~ /^#/' \
| xargs -r apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/*-run-deps.txt; \
\
for v in ${PYTHON_NON_DEFAULT}; do \
python${v} -m pip install --no-cache-dir --upgrade pip setuptools wheel; \
for shim in python${v} pip${v}; do \
[ -x "/usr/local/bin/${shim}" ] && ln -sf "/usr/local/bin/${shim}" "/usr/bin/${shim}"; \
done; \
done; \
python${PYTHON_DEFAULT} -m pip install --no-cache-dir --upgrade pip setuptools wheel; \
# Rewrite pip scripts (old pip uninstalls delete siblings' pipX.Y); default last owns pip/pip3
for v in ${PYTHON_NON_DEFAULT} ${PYTHON_DEFAULT}; do \
python${v} -m pip install --no-cache-dir --force-reinstall --no-deps pip; \
done; \
for shim in python python3 python${PYTHON_DEFAULT} pip pip3 pip${PYTHON_DEFAULT}; do \
ln -sf "/usr/local/bin/${shim}" "/usr/bin/${shim}"; \
done