1
+ FROM buildpack-deps:bookworm
2
+
3
+ LABEL \
4
+ maintainer=
"César Román <[email protected] >" \
5
+ repository="https://github.com/coatl-dev/docker-python" \
6
+ vendor="coatl.dev"
7
+
8
+ ENV DEBIAN_FRONTEND=noninteractive
9
+
10
+ ENV PIP_NO_CACHE_DIR=1
11
+ ENV PIP_NO_PYTHON_VERSION_WARNING=1
12
+ ENV PIP_ROOT_USER_ACTION=ignore
13
+
14
+ # ensure local python is preferred over distribution python
15
+ ENV PATH=/usr/local/bin:$PATH
16
+
17
+ # runtime dependencies
18
+ RUN set -eux; \
19
+ apt-get update; \
20
+ apt-get install -y --no-install-recommends \
21
+ libbluetooth-dev \
22
+ tk-dev \
23
+ uuid-dev \
24
+ ; \
25
+ rm -rf /var/lib/apt/lists/*
26
+
27
+ ENV PYTHON_VERSION=3.13.0
28
+
29
+ RUN set -eux; \
30
+ \
31
+ wget -q -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" ; \
32
+ mkdir -p /usr/src/python; \
33
+ tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \
34
+ rm python.tar.xz; \
35
+ \
36
+ cd /usr/src/python; \
37
+ gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ; \
38
+ ./configure \
39
+ --build="$gnuArch" \
40
+ --enable-loadable-sqlite-extensions \
41
+ --enable-optimizations \
42
+ --enable-option-checking=fatal \
43
+ --enable-shared \
44
+ --with-lto \
45
+ --with-system-expat \
46
+ --with-ensurepip \
47
+ ; \
48
+ nproc="$(nproc)" ; \
49
+ EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)" ; \
50
+ LDFLAGS="$(dpkg-buildflags --get LDFLAGS)" ; \
51
+ make -s -j "$nproc" \
52
+ "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
53
+ "LDFLAGS=${LDFLAGS:-}" \
54
+ "PROFILE_TASK=${PROFILE_TASK:-}" \
55
+ ; \
56
+ # https://github.com/docker-library/python/issues/784
57
+ # prevent accidental usage of a system installed libpython of the same version
58
+ rm python; \
59
+ make -s -j "$nproc" \
60
+ "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
61
+ "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ ORIGIN/../lib'" \
62
+ "PROFILE_TASK=${PROFILE_TASK:-}" \
63
+ python \
64
+ ; \
65
+ make install; \
66
+ \
67
+ # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701
68
+ bin="$(readlink -ve /usr/local/bin/python3)" ; \
69
+ dir="$(dirname " $bin")" ; \
70
+ mkdir -p "/usr/share/gdb/auto-load/$dir" ; \
71
+ cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py" ; \
72
+ \
73
+ cd /; \
74
+ rm -rf /usr/src/python; \
75
+ \
76
+ find /usr/local -depth \
77
+ \( \
78
+ \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
79
+ -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
80
+ \) -exec rm -rf '{}' + \
81
+ ; \
82
+ \
83
+ ldconfig; \
84
+ \
85
+ export PYTHONDONTWRITEBYTECODE=1; \
86
+ python3 --version; \
87
+ pip3 --version
88
+
89
+ # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
90
+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
91
+ RUN set -eux; \
92
+ for src in idle3 pip3 pydoc3 python3 python3-config; do \
93
+ dst="$(echo " $src" | tr -d 3)" ; \
94
+ [ -s "/usr/local/bin/$src" ]; \
95
+ [ ! -e "/usr/local/bin/$dst" ]; \
96
+ ln -svT "$src" "/usr/local/bin/$dst" ; \
97
+ done
98
+
99
+ CMD ["python3" ]
0 commit comments