|
| 1 | +# DO NOT MODIFY MANUALLY |
| 2 | +# GENERATED FROM SCRIPTS |
| 3 | +FROM ubuntu:18.04@sha256:3235326357dfb65f1781dbc4df3b834546d8bf914e82cce58e6e6b676e23ce8f |
| 4 | + |
| 5 | +# Avoid tzdata interactive action |
| 6 | +ENV DEBIAN_FRONTEND noninteractive |
| 7 | + |
| 8 | +# Adding Python to image |
| 9 | + |
| 10 | +# Dockerfile generated fragment to install Python and Pip |
| 11 | +# Source: https://raw.githubusercontent.com/docker-library/python/master/3.7/buster/slim/Dockerfile |
| 12 | +# Python: 3.7.7 |
| 13 | +# Pip: 20.1 |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +# ensure local python is preferred over distribution python |
| 19 | +ENV PATH /usr/local/bin:$PATH |
| 20 | + |
| 21 | +# http://bugs.python.org/issue19846 |
| 22 | +# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. |
| 23 | +ENV LANG C.UTF-8 |
| 24 | + |
| 25 | +# runtime dependencies |
| 26 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 27 | + ca-certificates \ |
| 28 | + netbase \ |
| 29 | + && rm -rf /var/lib/apt/lists/* |
| 30 | + |
| 31 | +ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D |
| 32 | +ENV PYTHON_VERSION 3.7.7 |
| 33 | + |
| 34 | +RUN set -ex \ |
| 35 | + \ |
| 36 | + && savedAptMark="$(apt-mark showmanual)" \ |
| 37 | + && apt-get update && apt-get install -y --no-install-recommends \ |
| 38 | + dpkg-dev \ |
| 39 | + gcc \ |
| 40 | + libbluetooth-dev \ |
| 41 | + libbz2-dev \ |
| 42 | + libc6-dev \ |
| 43 | + libexpat1-dev \ |
| 44 | + libffi-dev \ |
| 45 | + libgdbm-dev \ |
| 46 | + liblzma-dev \ |
| 47 | + libncursesw5-dev \ |
| 48 | + libreadline-dev \ |
| 49 | + libsqlite3-dev \ |
| 50 | + libssl-dev \ |
| 51 | + make \ |
| 52 | + tk-dev \ |
| 53 | + uuid-dev \ |
| 54 | + wget \ |
| 55 | + xz-utils \ |
| 56 | + zlib1g-dev \ |
| 57 | +# as of Stretch, "gpg" is no longer included by default |
| 58 | + $(command -v gpg > /dev/null || echo 'gnupg dirmngr') \ |
| 59 | + \ |
| 60 | + && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ |
| 61 | + && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ |
| 62 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 63 | +# Fix to avoid GPG server problem |
| 64 | + && echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf \ |
| 65 | + && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ |
| 66 | + && gpg --batch --verify python.tar.xz.asc python.tar.xz \ |
| 67 | + && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ |
| 68 | + && rm -rf "$GNUPGHOME" python.tar.xz.asc \ |
| 69 | + && mkdir -p /usr/src/python \ |
| 70 | + && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ |
| 71 | + && rm python.tar.xz \ |
| 72 | + \ |
| 73 | + && cd /usr/src/python \ |
| 74 | + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ |
| 75 | + && ./configure \ |
| 76 | + --build="$gnuArch" \ |
| 77 | + --enable-loadable-sqlite-extensions \ |
| 78 | + --enable-optimizations \ |
| 79 | + --enable-option-checking=fatal \ |
| 80 | + --enable-shared \ |
| 81 | + --with-system-expat \ |
| 82 | + --with-system-ffi \ |
| 83 | + --without-ensurepip \ |
| 84 | + && make -j "$(nproc)" \ |
| 85 | +# setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 |
| 86 | + PROFILE_TASK='-m test.regrtest --pgo \ |
| 87 | + test_array \ |
| 88 | + test_base64 \ |
| 89 | + test_binascii \ |
| 90 | + test_binhex \ |
| 91 | + test_binop \ |
| 92 | + test_bytes \ |
| 93 | + test_c_locale_coercion \ |
| 94 | + test_class \ |
| 95 | + test_cmath \ |
| 96 | + test_codecs \ |
| 97 | + test_compile \ |
| 98 | + test_complex \ |
| 99 | + test_csv \ |
| 100 | + test_decimal \ |
| 101 | + test_dict \ |
| 102 | + test_float \ |
| 103 | + test_fstring \ |
| 104 | + test_hashlib \ |
| 105 | + test_io \ |
| 106 | + test_iter \ |
| 107 | + test_json \ |
| 108 | + test_long \ |
| 109 | + test_math \ |
| 110 | + test_memoryview \ |
| 111 | + test_pickle \ |
| 112 | + test_re \ |
| 113 | + test_set \ |
| 114 | + test_slice \ |
| 115 | + test_struct \ |
| 116 | + test_threading \ |
| 117 | + test_time \ |
| 118 | + test_traceback \ |
| 119 | + test_unicode \ |
| 120 | + ' \ |
| 121 | + && make install \ |
| 122 | + && ldconfig \ |
| 123 | + \ |
| 124 | + && apt-mark auto '.*' > /dev/null \ |
| 125 | + && apt-mark manual $savedAptMark \ |
| 126 | + && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ |
| 127 | + | awk '/=>/ { print $(NF-1) }' \ |
| 128 | + | sort -u \ |
| 129 | + | xargs -r dpkg-query --search \ |
| 130 | + | cut -d: -f1 \ |
| 131 | + | sort -u \ |
| 132 | + | xargs -r apt-mark manual \ |
| 133 | + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ |
| 134 | + && rm -rf /var/lib/apt/lists/* \ |
| 135 | + \ |
| 136 | + && find /usr/local -depth \ |
| 137 | + \( \ |
| 138 | + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ |
| 139 | + -o \ |
| 140 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 141 | + \) -exec rm -rf '{}' + \ |
| 142 | + && rm -rf /usr/src/python \ |
| 143 | + \ |
| 144 | + && python3 --version |
| 145 | + |
| 146 | +# make some useful symlinks that are expected to exist |
| 147 | +RUN cd /usr/local/bin \ |
| 148 | + && ln -s idle3 idle \ |
| 149 | + && ln -s pydoc3 pydoc \ |
| 150 | + && ln -s python3 python \ |
| 151 | + && ln -s python3-config python-config |
| 152 | + |
| 153 | +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" |
| 154 | +ENV PYTHON_PIP_VERSION 20.1 |
| 155 | +# https://github.com/pypa/get-pip |
| 156 | +ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/1fe530e9e3d800be94e04f6428460fc4fb94f5a9/get-pip.py |
| 157 | +ENV PYTHON_GET_PIP_SHA256 ce486cddac44e99496a702aa5c06c5028414ef48fdfd5242cd2fe559b13d4348 |
| 158 | + |
| 159 | +RUN set -ex; \ |
| 160 | + \ |
| 161 | + savedAptMark="$(apt-mark showmanual)"; \ |
| 162 | + apt-get update; \ |
| 163 | + apt-get install -y --no-install-recommends wget; \ |
| 164 | + \ |
| 165 | + wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \ |
| 166 | + echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum --check --strict -; \ |
| 167 | + \ |
| 168 | + apt-mark auto '.*' > /dev/null; \ |
| 169 | + [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \ |
| 170 | + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ |
| 171 | + rm -rf /var/lib/apt/lists/*; \ |
| 172 | + \ |
| 173 | + python get-pip.py \ |
| 174 | + --disable-pip-version-check \ |
| 175 | + --no-cache-dir \ |
| 176 | + "pip==$PYTHON_PIP_VERSION" \ |
| 177 | + ; \ |
| 178 | + pip --version; \ |
| 179 | + \ |
| 180 | + find /usr/local -depth \ |
| 181 | + \( \ |
| 182 | + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ |
| 183 | + -o \ |
| 184 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 185 | + \) -exec rm -rf '{}' +; \ |
| 186 | + rm -f get-pip.py |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | +# Adding MKL-DNN (now OneDNN) to the image |
| 191 | +RUN savedAptMark="$(apt-mark showmanual)" \ |
| 192 | +&& apt update \ |
| 193 | +&& apt install gcc g++ make cmake git gfortran -y --no-install-recommends \ |
| 194 | +&& git clone https://github.com/01org/mkl-dnn.git -b v0.21.5 --depth 1 \ |
| 195 | +&& cd mkl-dnn/scripts && ./prepare_mkl.sh && cd .. \ |
| 196 | +&& mkdir -p build && cd build && cmake .. && make \ |
| 197 | +&& make install \ |
| 198 | +&& apt-mark auto '.*' > /dev/null \ |
| 199 | +&& apt-mark manual $savedAptMark \ |
| 200 | +&& apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ |
| 201 | +&& apt autoclean \ |
| 202 | +&& apt clean \ |
| 203 | +&& rm -rf /var/lib/apt/lists/* |
| 204 | + |
| 205 | +ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib |
| 206 | + |
0 commit comments