1
+ # vim: ft=Dockerfile sw=4 ts=4 expandtab
1
2
# ##############################################################################
2
3
#
3
4
# Multi-stage Python 3.x build
@@ -43,11 +44,11 @@ COPY ./init-functions /lib/lsb/
43
44
44
45
RUN set -ex \
45
46
&& apt-mark unhold apt gnupg libcap2 libsemanage1 passwd libbz2-1.0\
46
- && runDeps='curl gnupg libsqlite3-0 zlib1g libexpat1 bash tcpdump procps less binutils libbz2-1.0 netcat-openbsd git' \
47
+ && runDeps='curl gnupg libsqlite3-0 zlib1g libexpat1 bash tcpdump procps less binutils libbz2-1.0 netcat-openbsd git' \
47
48
&& apt-get -qq update; apt-get install -y $runDeps \
48
- && find /usr -type f -name "*.so" -exec strip --strip-unneeded {} + \
49
- && apt-get remove binutils --purge -y -qq \
50
- && find /var/lib/apt/lists \
49
+ && find /usr -type f -name "*.so" -exec strip --strip-unneeded {} + \
50
+ && apt-get remove binutils --purge -y -qq \
51
+ && find /var/lib/apt/lists \
51
52
/usr/share/man \
52
53
/usr/share/doc \
53
54
/var/log \
@@ -66,17 +67,17 @@ ADD gnupg/pubring.gpg gnupg/trustdb.gpg /root/.gnupg/
66
67
RUN set -ex \
67
68
&& mkdir -p /root/.gnupg \
68
69
&& chmod 700 /root/.gnupg \
69
- && buildDeps='libsqlite3-dev zlib1g-dev libexpat1-dev libssl-dev xz-utils dpkg-dev binutils libbz2-dev libreadline-dev' \
70
- && apt-get -qq update; apt-get -qq -y install ${buildDeps}
70
+ && buildDeps='libsqlite3-dev zlib1g-dev libexpat1-dev libssl-dev xz-utils dpkg-dev binutils libbz2-dev libreadline-dev' \
71
+ && apt-get -qq update; apt-get -qq -y install ${buildDeps}
71
72
72
73
ARG PYTHON_VERSION
73
74
74
75
RUN curl -L -o /python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
75
76
&& curl -L -o /python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
76
- && gpg --keyserver ha.pool.sks-keyservers.net --refresh-keys 2>&1 | egrep -v 'requesting key|not changed' \
77
- && gpg --batch --verify /python.tar.xz.asc /python.tar.xz \
78
- && mkdir -p /usr/src/python \
79
- && tar -xJC /usr/src/python --strip-components=1 -f /python.tar.xz
77
+ && gpg --keyserver ha.pool.sks-keyservers.net --refresh-keys 2>&1 | egrep -v 'requesting key|not changed' \
78
+ && gpg --batch --verify /python.tar.xz.asc /python.tar.xz \
79
+ && mkdir -p /usr/src/python \
80
+ && tar -xJC /usr/src/python --strip-components=1 -f /python.tar.xz
80
81
81
82
82
83
LABEL stage BUILD-SETUP
@@ -90,30 +91,30 @@ ARG PYTHON_VERSION
90
91
ENV LANG C.UTF-8
91
92
92
93
RUN set -ex \
93
- && cd /usr/src/python \
94
- && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
94
+ && cd /usr/src/python \
95
+ && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
95
96
&& [ $(( ` echo $PYTHON_VERSION | cut -d"." -f1 ` )) -lt 3 ] && BUILD_ARGS="" \
96
- ; ./configure \
97
- --build="$gnuArch" \
98
- --enable-loadable-sqlite-extensions \
99
- --enable-shared \
100
- --with-system-expat \
101
- --with-system-ffi \
102
- --without-ensurepip ${BUILD_ARGS} \
103
- && make -j $(( 1 * $( egrep '^processor[[:space:]]+:' /proc/cpuinfo | wc -l ) )) \
104
- && make install
97
+ ; ./configure \
98
+ --build="$gnuArch" \
99
+ --enable-loadable-sqlite-extensions \
100
+ --enable-shared \
101
+ --with-system-expat \
102
+ --with-system-ffi \
103
+ --without-ensurepip ${BUILD_ARGS} \
104
+ && make -j $(( 1 * $( egrep '^processor[[:space:]]+:' /proc/cpuinfo | wc -l ) )) \
105
+ && make install
105
106
106
107
RUN set -ex \
107
- find /usr/local -type f -name "*.so" -exec strip --strip-unneeded {} + \
108
+ find /usr/local -type f -name "*.so" -exec strip --strip-unneeded {} + \
108
109
& ldconfig \
109
110
& find /usr/local -depth \
110
- \( \
111
- \( -type d -a \( -name test -o -name tests -o -name __pycache__ \) \) \
112
- -o \
113
- \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
114
- -o \
115
- \( -name "idle*" \) \
116
- \) -exec rm -rf '{}' + \
111
+ \( \
112
+ \( -type d -a \( -name test -o -name tests -o -name __pycache__ \) \) \
113
+ -o \
114
+ \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
115
+ -o \
116
+ \( -name "idle*" \) \
117
+ \) -exec rm -rf '{}' + \
117
118
&& find /var/lib/apt/lists \
118
119
/usr/share/man \
119
120
/usr/share/doc \
@@ -132,27 +133,26 @@ FROM builder as post-build
132
133
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
133
134
ENV PYTHON_PIP_VERSION 9.0.1
134
135
135
-
136
136
COPY ./ipython_config.py /
137
137
138
138
RUN set -ex; ldconfig
139
139
RUN set -ex; curl -sL -o get-pip.py 'https://bootstrap.pypa.io/get-pip.py' ;
140
140
RUN set -ex; python get-pip.py \
141
- --disable-pip-version-check \
142
- --no-cache-dir \
143
- "pip==$PYTHON_PIP_VERSION" ; pip --version
141
+ --disable-pip-version-check \
142
+ --no-cache-dir \
143
+ "pip==$PYTHON_PIP_VERSION" ; pip --version
144
144
145
145
RUN mkdir -p $HOME/.ipython/profile_default ;
146
146
RUN mv ipython_config.py $HOME/.ipython/profile_default/. ;
147
147
RUN pip install 'ipython<6' ipdb
148
148
149
149
RUN set -ex; \
150
- find /usr/local -depth \
151
- \( \
152
- \( -type d -a \( -name test -o -name tests -o -name __pycache__ \) \) \
153
- -o \
154
- \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.exe' \) \) \
155
- \) -exec rm -rf '{}' +;
150
+ find /usr/local -depth \
151
+ \( \
152
+ \( -type d -a \( -name test -o -name tests -o -name __pycache__ \) \) \
153
+ -o \
154
+ \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.exe' \) \) \
155
+ \) -exec rm -rf '{}' +;
156
156
157
157
RUN rm -rf /root/.cache
158
158
@@ -165,6 +165,7 @@ FROM runtime
165
165
166
166
COPY --from=post-build /usr/local /usr/local
167
167
COPY --from=post-build /root /root
168
+
168
169
RUN /sbin/ldconfig
169
170
170
171
LABEL stage FINAL
0 commit comments