11FROM alpine:3.4
22
3+ # ensure local python is preferred over distribution python
4+ ENV PATH /usr/local/bin:$PATH
5+
36# http://bugs.python.org/issue19846
47# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
58ENV LANG C.UTF-8
@@ -8,18 +11,21 @@ ENV LANG C.UTF-8
811# the other runtime dependencies for Python are installed later
912RUN apk add --no-cache ca-certificates
1013
11- # gpg: key 18ADD4FF: public key "Benjamin Peterson <benjamin@python.org>" imported
1214ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
13-
1415ENV PYTHON_VERSION 2.7.12
1516
1617# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
1718ENV PYTHON_PIP_VERSION 8.1.2
1819
1920RUN set -ex \
20- && apk add --no-cache --virtual .fetch-deps curl gnupg tar xz \
21- && curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
22- && curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
21+ && apk add --no-cache --virtual .fetch-deps \
22+ gnupg \
23+ openssl \
24+ tar \
25+ xz \
26+ \
27+ && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
28+ && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
2329 && export GNUPGHOME="$(mktemp -d)" \
2430 && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
2531 && gpg --batch --verify python.tar.xz.asc python.tar.xz \
@@ -35,6 +41,7 @@ RUN set -ex \
3541 linux-headers \
3642 make \
3743 ncurses-dev \
44+ openssl \
3845 openssl-dev \
3946 pax-utils \
4047 readline-dev \
@@ -43,15 +50,22 @@ RUN set -ex \
4350 tk \
4451 tk-dev \
4552 zlib-dev \
53+ # add build deps before removing fetch deps in case there's overlap
54+ && apk del .fetch-deps \
55+ \
4656 && cd /usr/src/python \
4757 && ./configure \
4858 --enable-shared \
4959 --enable-unicode=ucs4 \
5060 && make -j$(getconf _NPROCESSORS_ONLN) \
5161 && make install \
52- && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
53- && pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
54- && [ "$(pip list | awk -F '[ ()]+' '$1 == " pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
62+ \
63+ && wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
64+ && python2 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
65+ && rm /tmp/get-pip.py \
66+ && pip install --no-cache-dir --upgrade "pip==$PYTHON_PIP_VERSION" \
67+ && [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == " pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
68+ \
5569 && find /usr/local -depth \
5670 \( \
5771 \( -type d -a -name test -o -name tests \) \
@@ -66,7 +80,7 @@ RUN set -ex \
6680 | sort -u \
6781 )" \
6882 && apk add --virtual .python-rundeps $runDeps \
69- && apk del .build-deps .fetch-deps \
83+ && apk del .build-deps \
7084 && rm -rf /usr/src/python ~/.cache
7185
7286CMD ["python2" ]
0 commit comments