1
- # vim: ft=Dockerfile ts=4 sw=4 expandtab
1
+ # vim: ft=dockerfile ts=4 sw=4 expandtab
2
2
# ##############################################################################
3
3
#
4
4
# Multi-stage Python 3.x build
@@ -47,7 +47,7 @@ RUN set -ex \
47
47
&& apt update \
48
48
&& apt -y upgrade \
49
49
&& apt-mark unhold apt libcap2 libsemanage1 passwd \
50
- && apt-get install --no-install-recommends -qq -y libsqlite3-0 zlib1g libexpat1 bash procps less libbz2-1.0 netcat-openbsd git binutils \
50
+ && apt-get install --no-install-recommends -qq -y ca-certificates libsqlite3-0 zlib1g libexpat1 bash procps less libbz2-1.0 netcat-openbsd git binutils \
51
51
&& find /usr -type f -name "*.so" -exec strip --strip-unneeded {} + \
52
52
&& apt-get remove -qq --allow-remove-essential --purge -y -qq \
53
53
binutils e2fsprogs e2fslibs libx11-6 libx11-data \
@@ -65,12 +65,21 @@ LABEL stage RUNTIME
65
65
# ##############################################################################
66
66
FROM scratch as runtime
67
67
68
+ ENV PATH /usr/local/bin:$PATH
69
+
70
+ # http://bugs.python.org/issue19846
71
+ # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
72
+ ENV LANG C.UTF-8
73
+
74
+ COPY ./init-functions /lib/lsb/
75
+
68
76
COPY --from=base / /
69
77
70
78
# ##############################################################################
71
79
FROM alpine as source-download
72
80
73
81
ARG PYTHON_VERSION
82
+ ENV PYTHON_VERSION ${PYTHON_VERSION}
74
83
75
84
ENV SRCDIR /python
76
85
RUN apk add curl
@@ -83,8 +92,6 @@ FROM runtime as build-setup
83
92
84
93
WORKDIR /python
85
94
86
- ARG PYTHON_VERSION
87
-
88
95
RUN apt-get update
89
96
RUN apt-get -y install --no-install-recommends \
90
97
libsqlite3-dev zlib1g-dev libexpat1-dev \
@@ -94,9 +101,6 @@ RUN apt-get -y install --no-install-recommends \
94
101
gcc g++ make autoconf libtool \
95
102
dpkg-dev
96
103
97
- # COPY --from=source-download /${PYTHON_VERSION} /python
98
-
99
-
100
104
LABEL stage BUILD-SETUP
101
105
102
106
# ##############################################################################
@@ -110,12 +114,9 @@ ENV CFLAGS -I/usr/include/openssl
110
114
111
115
WORKDIR /build
112
116
113
- RUN --mount=type=bind,from=source-download,target=/python,source=/python \
114
- --mount=type=cache,target=/tmp \
115
- --mount=type=cache,target=/var/tmp \
116
- --mount=type=cache,target=/var/log \
117
- --mount=type=cache,target=/root \
118
- set -ex \
117
+ COPY --from=source-download /python /python
118
+
119
+ RUN set -ex \
119
120
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
120
121
&& [ $(( ` echo $PYTHON_VERSION | cut -d"." -f1 ` )) -lt 3 ] && BUILD_ARGS="" \
121
122
; ../python/configure \
@@ -126,12 +127,7 @@ RUN --mount=type=bind,from=source-download,target=/python,source=/python \
126
127
--with-system-ffi \
127
128
--without-ensurepip ${BUILD_ARGS}
128
129
129
- RUN --mount=type=bind,from=source-download,target=/python,source=/python \
130
- --mount=type=cache,target=/tmp \
131
- --mount=type=cache,target=/var/tmp \
132
- --mount=type=cache,target=/var/log \
133
- --mount=type=cache,target=/root \
134
- make -j $(( 1 * $( egrep '^processor[[:space:]]+:' /proc/cpuinfo | wc -l ) )) \
130
+ RUN make -j $(( 1 * $( egrep '^processor[[:space:]]+:' /proc/cpuinfo | wc -l ) )) \
135
131
&& make install
136
132
137
133
RUN set -ex \
@@ -161,7 +157,7 @@ LABEL version ${PYTHON_VERSION}
161
157
FROM builder as post-build
162
158
163
159
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
164
- ENV PYTHON_PIP_VERSION 19.1.1
160
+ ENV PYTHON_PIP_VERSION 22.2.2
165
161
166
162
167
163
ADD https://bootstrap.pypa.io/get-pip.py .
@@ -191,10 +187,11 @@ LABEL stage POST-BUILD
191
187
LABEL version ${PYTHON_VERSION}
192
188
193
189
# ##############################################################################
194
- FROM runtime as final
190
+ FROM runtime as release
195
191
196
192
COPY --from=post-build /usr/local /usr/local
197
193
COPY --from=post-build /root/* /root/
194
+
198
195
RUN /sbin/ldconfig
199
196
200
197
LABEL stage FINAL
0 commit comments