Skip to content

Commit db1e5ea

Browse files
committed
Merge branch 'master' of github.com:revsys/optimized-python-docker
2 parents 8d7ea11 + 4493f33 commit db1e5ea

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

Dockerfile

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# vim: ft=Dockerfile sw=4 ts=4 expandtab
12
###############################################################################
23
#
34
# Multi-stage Python 3.x build
@@ -43,11 +44,11 @@ COPY ./init-functions /lib/lsb/
4344

4445
RUN set -ex \
4546
&& 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' \
4748
&& 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 \
5152
/usr/share/man \
5253
/usr/share/doc \
5354
/var/log \
@@ -66,17 +67,17 @@ ADD gnupg/pubring.gpg gnupg/trustdb.gpg /root/.gnupg/
6667
RUN set -ex \
6768
&& mkdir -p /root/.gnupg \
6869
&& 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}
7172

7273
ARG PYTHON_VERSION
7374

7475
RUN curl -L -o /python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
7576
&& 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
8081

8182

8283
LABEL stage BUILD-SETUP
@@ -90,30 +91,30 @@ ARG PYTHON_VERSION
9091
ENV LANG C.UTF-8
9192

9293
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)" \
9596
&& [ $(( ` 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
105106

106107
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 {} + \
108109
& ldconfig \
109110
& 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 '{}' + \
117118
&& find /var/lib/apt/lists \
118119
/usr/share/man \
119120
/usr/share/doc \
@@ -132,27 +133,26 @@ FROM builder as post-build
132133
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
133134
ENV PYTHON_PIP_VERSION 9.0.1
134135

135-
136136
COPY ./ipython_config.py /
137137

138138
RUN set -ex; ldconfig
139139
RUN set -ex; curl -sL -o get-pip.py 'https://bootstrap.pypa.io/get-pip.py';
140140
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
144144

145145
RUN mkdir -p $HOME/.ipython/profile_default ;
146146
RUN mv ipython_config.py $HOME/.ipython/profile_default/. ;
147147
RUN pip install 'ipython<6' ipdb
148148

149149
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 '{}' +;
156156

157157
RUN rm -rf /root/.cache
158158

@@ -165,6 +165,7 @@ FROM runtime
165165

166166
COPY --from=post-build /usr/local /usr/local
167167
COPY --from=post-build /root /root
168+
168169
RUN /sbin/ldconfig
169170

170171
LABEL stage FINAL

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy