1- # vim: ft=Dockerfile ts=4 sw=4 expandtab
1+ # vim: ft=dockerfile ts=4 sw=4 expandtab
22# ##############################################################################
33#
44# Multi-stage Python 3.x build
@@ -47,7 +47,7 @@ RUN set -ex \
4747 && apt update \
4848 && apt -y upgrade \
4949 && 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 \
5151 && find /usr -type f -name "*.so" -exec strip --strip-unneeded {} + \
5252 && apt-get remove -qq --allow-remove-essential --purge -y -qq \
5353 binutils e2fsprogs e2fslibs libx11-6 libx11-data \
@@ -65,12 +65,21 @@ LABEL stage RUNTIME
6565# ##############################################################################
6666FROM scratch as runtime
6767
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+
6876COPY --from=base / /
6977
7078# ##############################################################################
7179FROM alpine as source-download
7280
7381ARG PYTHON_VERSION
82+ ENV PYTHON_VERSION ${PYTHON_VERSION}
7483
7584ENV SRCDIR /python
7685RUN apk add curl
@@ -83,8 +92,6 @@ FROM runtime as build-setup
8392
8493WORKDIR /python
8594
86- ARG PYTHON_VERSION
87-
8895RUN apt-get update
8996RUN apt-get -y install --no-install-recommends \
9097 libsqlite3-dev zlib1g-dev libexpat1-dev \
@@ -94,9 +101,6 @@ RUN apt-get -y install --no-install-recommends \
94101 gcc g++ make autoconf libtool \
95102 dpkg-dev
96103
97- # COPY --from=source-download /${PYTHON_VERSION} /python
98-
99-
100104LABEL stage BUILD-SETUP
101105
102106# ##############################################################################
@@ -110,12 +114,9 @@ ENV CFLAGS -I/usr/include/openssl
110114
111115WORKDIR /build
112116
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 \
119120 && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
120121 && [ $(( ` echo $PYTHON_VERSION | cut -d"." -f1 ` )) -lt 3 ] && BUILD_ARGS="" \
121122 ; ../python/configure \
@@ -126,12 +127,7 @@ RUN --mount=type=bind,from=source-download,target=/python,source=/python \
126127 --with-system-ffi \
127128 --without-ensurepip ${BUILD_ARGS}
128129
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 ) )) \
135131 && make install
136132
137133RUN set -ex \
@@ -161,7 +157,7 @@ LABEL version ${PYTHON_VERSION}
161157FROM builder as post-build
162158
163159# 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
165161
166162
167163ADD https://bootstrap.pypa.io/get-pip.py .
@@ -191,10 +187,11 @@ LABEL stage POST-BUILD
191187LABEL version ${PYTHON_VERSION}
192188
193189# ##############################################################################
194- FROM runtime as final
190+ FROM runtime as release
195191
196192COPY --from=post-build /usr/local /usr/local
197193COPY --from=post-build /root/* /root/
194+
198195RUN /sbin/ldconfig
199196
200197LABEL stage FINAL
0 commit comments