python_sonar/3.6/Dockerfile

65 lines
2.2 KiB
Docker
Raw Normal View History

2016-07-02 01:30:37 +08:00
FROM buildpack-deps:jessie
# ensure local python is used over debian python
ENV PATH /usr/local/bin:$PATH
2016-07-02 01:30:37 +08:00
# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8
2016-07-02 01:54:12 +08:00
# gpg: key AA65421D: public key "Ned Deily (Python release signing key) <nad@acm.org>" imported
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
2016-08-03 21:20:27 +08:00
ENV PYTHON_VERSION 3.6.0a3
2016-07-02 01:30:37 +08:00
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 8.1.2
RUN set -ex \
&& buildDeps=' \
tcl-dev \
tk-dev \
' \
&& runDeps=' \
tcl \
tk \
' \
&& apt-get update && apt-get install -y $runDeps $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
2016-07-02 01:30:37 +08:00
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
&& export GNUPGHOME="$(mktemp -d)" \
2016-07-02 01:54:12 +08:00
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
2016-07-02 01:30:37 +08:00
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& rm -r "$GNUPGHOME" python.tar.xz.asc \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
\
&& cd /usr/src/python \
&& ./configure \
--enable-loadable-sqlite-extensions \
--enable-shared \
2016-07-02 01:30:37 +08:00
&& make -j$(nproc) \
&& make install \
&& ldconfig \
&& pip3 install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
&& [ "$(pip list | awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
&& find /usr/local -depth \
\( \
2016-08-06 06:35:57 +08:00
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
2016-07-02 01:30:37 +08:00
\) -exec rm -rf '{}' + \
&& apt-get purge -y --auto-remove $buildDeps \
2016-07-02 01:30:37 +08:00
&& rm -rf /usr/src/python ~/.cache
# make some useful symlinks that are expected to exist
RUN cd /usr/local/bin \
&& ln -s easy_install-3.6 easy_install \
&& ln -s idle3 idle \
&& ln -s pydoc3 pydoc \
&& ln -s python3 python \
&& ln -s python3-config python-config
CMD ["python3"]