|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | + |
| 7 | +FROM debian:buster-slim |
| 8 | + |
| 9 | +# ensure local python is preferred over distribution python |
| 10 | +ENV PATH /usr/local/bin:$PATH |
| 11 | + |
| 12 | +# http://bugs.python.org/issue19846 |
| 13 | +# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. |
| 14 | +ENV LANG C.UTF-8 |
| 15 | + |
| 16 | +# runtime dependencies |
| 17 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 18 | + ca-certificates \ |
| 19 | + netbase \ |
| 20 | + && rm -rf /var/lib/apt/lists/* |
| 21 | + |
| 22 | +ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D |
| 23 | +ENV PYTHON_VERSION 3.6.9 |
| 24 | + |
| 25 | +RUN set -ex \ |
| 26 | + \ |
| 27 | + && savedAptMark="$(apt-mark showmanual)" \ |
| 28 | + && apt-get update && apt-get install -y --no-install-recommends \ |
| 29 | + dpkg-dev \ |
| 30 | + gcc \ |
| 31 | + libbz2-dev \ |
| 32 | + libc6-dev \ |
| 33 | + libexpat1-dev \ |
| 34 | + libffi-dev \ |
| 35 | + libgdbm-dev \ |
| 36 | + liblzma-dev \ |
| 37 | + libncursesw5-dev \ |
| 38 | + libreadline-dev \ |
| 39 | + libsqlite3-dev \ |
| 40 | + libssl-dev \ |
| 41 | + make \ |
| 42 | + tk-dev \ |
| 43 | + wget \ |
| 44 | + xz-utils \ |
| 45 | + zlib1g-dev \ |
| 46 | +# as of Stretch, "gpg" is no longer included by default |
| 47 | + $(command -v gpg > /dev/null || echo 'gnupg dirmngr') \ |
| 48 | + \ |
| 49 | + && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ |
| 50 | + && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ |
| 51 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 52 | + && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ |
| 53 | + && gpg --batch --verify python.tar.xz.asc python.tar.xz \ |
| 54 | + && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ |
| 55 | + && rm -rf "$GNUPGHOME" python.tar.xz.asc \ |
| 56 | + && mkdir -p /usr/src/python \ |
| 57 | + && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ |
| 58 | + && rm python.tar.xz \ |
| 59 | + \ |
| 60 | + && cd /usr/src/python \ |
| 61 | + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ |
| 62 | + && ./configure \ |
| 63 | + --build="$gnuArch" \ |
| 64 | + --enable-loadable-sqlite-extensions \ |
| 65 | + --enable-optimizations \ |
| 66 | + --enable-shared \ |
| 67 | + --with-system-expat \ |
| 68 | + --with-system-ffi \ |
| 69 | + --without-ensurepip \ |
| 70 | + && make -j "$(nproc)" \ |
| 71 | +# https://github.com/docker-library/python/issues/160#issuecomment-509426916 |
| 72 | + PROFILE_TASK='-m test.regrtest --pgo \ |
| 73 | + test_array \ |
| 74 | + test_base64 \ |
| 75 | + test_binascii \ |
| 76 | + test_binhex \ |
| 77 | + test_binop \ |
| 78 | + test_bytes \ |
| 79 | + test_c_locale_coercion \ |
| 80 | + test_class \ |
| 81 | + test_cmath \ |
| 82 | + test_codecs \ |
| 83 | + test_compile \ |
| 84 | + test_complex \ |
| 85 | + test_csv \ |
| 86 | + test_decimal \ |
| 87 | + test_dict \ |
| 88 | + test_float \ |
| 89 | + test_fstring \ |
| 90 | + test_hashlib \ |
| 91 | + test_io \ |
| 92 | + test_iter \ |
| 93 | + test_json \ |
| 94 | + test_long \ |
| 95 | + test_math \ |
| 96 | + test_memoryview \ |
| 97 | + test_pickle \ |
| 98 | + test_re \ |
| 99 | + test_set \ |
| 100 | + test_slice \ |
| 101 | + test_struct \ |
| 102 | + test_threading \ |
| 103 | + test_time \ |
| 104 | + test_traceback \ |
| 105 | + test_unicode \ |
| 106 | + ' \ |
| 107 | + && make install \ |
| 108 | + && ldconfig \ |
| 109 | + \ |
| 110 | + && apt-mark auto '.*' > /dev/null \ |
| 111 | + && apt-mark manual $savedAptMark \ |
| 112 | + && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ |
| 113 | + | awk '/=>/ { print $(NF-1) }' \ |
| 114 | + | sort -u \ |
| 115 | + | xargs -r dpkg-query --search \ |
| 116 | + | cut -d: -f1 \ |
| 117 | + | sort -u \ |
| 118 | + | xargs -r apt-mark manual \ |
| 119 | + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ |
| 120 | + && rm -rf /var/lib/apt/lists/* \ |
| 121 | + \ |
| 122 | + && find /usr/local -depth \ |
| 123 | + \( \ |
| 124 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 125 | + -o \ |
| 126 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 127 | + \) -exec rm -rf '{}' + \ |
| 128 | + && rm -rf /usr/src/python \ |
| 129 | + \ |
| 130 | + && python3 --version |
| 131 | + |
| 132 | +# make some useful symlinks that are expected to exist |
| 133 | +RUN cd /usr/local/bin \ |
| 134 | + && ln -s idle3 idle \ |
| 135 | + && ln -s pydoc3 pydoc \ |
| 136 | + && ln -s python3 python \ |
| 137 | + && ln -s python3-config python-config |
| 138 | + |
| 139 | +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" |
| 140 | +ENV PYTHON_PIP_VERSION 19.1.1 |
| 141 | + |
| 142 | +RUN set -ex; \ |
| 143 | + \ |
| 144 | + savedAptMark="$(apt-mark showmanual)"; \ |
| 145 | + apt-get update; \ |
| 146 | + apt-get install -y --no-install-recommends wget; \ |
| 147 | + \ |
| 148 | + wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \ |
| 149 | + \ |
| 150 | + apt-mark auto '.*' > /dev/null; \ |
| 151 | + [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \ |
| 152 | + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ |
| 153 | + rm -rf /var/lib/apt/lists/*; \ |
| 154 | + \ |
| 155 | + python get-pip.py \ |
| 156 | + --disable-pip-version-check \ |
| 157 | + --no-cache-dir \ |
| 158 | + "pip==$PYTHON_PIP_VERSION" \ |
| 159 | + ; \ |
| 160 | + pip --version; \ |
| 161 | + \ |
| 162 | + find /usr/local -depth \ |
| 163 | + \( \ |
| 164 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 165 | + -o \ |
| 166 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 167 | + \) -exec rm -rf '{}' +; \ |
| 168 | + rm -f get-pip.py |
| 169 | + |
| 170 | +CMD ["python3"] |
0 commit comments