|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | + |
| 7 | +FROM alpine:3.10 |
| 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 | +# install ca-certificates so that HTTPS works consistently |
| 17 | +# other runtime dependencies for Python are installed later |
| 18 | +RUN apk add --no-cache ca-certificates |
| 19 | + |
| 20 | +ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D |
| 21 | +ENV PYTHON_VERSION 3.5.7 |
| 22 | + |
| 23 | +RUN set -ex \ |
| 24 | + && apk add --no-cache --virtual .fetch-deps \ |
| 25 | + gnupg \ |
| 26 | + tar \ |
| 27 | + xz \ |
| 28 | + \ |
| 29 | + && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ |
| 30 | + && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ |
| 31 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 32 | + && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ |
| 33 | + && gpg --batch --verify python.tar.xz.asc python.tar.xz \ |
| 34 | + && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ |
| 35 | + && rm -rf "$GNUPGHOME" python.tar.xz.asc \ |
| 36 | + && mkdir -p /usr/src/python \ |
| 37 | + && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ |
| 38 | + && rm python.tar.xz \ |
| 39 | + \ |
| 40 | + && apk add --no-cache --virtual .build-deps \ |
| 41 | + bzip2-dev \ |
| 42 | + coreutils \ |
| 43 | + dpkg-dev dpkg \ |
| 44 | + expat-dev \ |
| 45 | + findutils \ |
| 46 | + gcc \ |
| 47 | + gdbm-dev \ |
| 48 | + libc-dev \ |
| 49 | + libffi-dev \ |
| 50 | + linux-headers \ |
| 51 | + make \ |
| 52 | + ncurses-dev \ |
| 53 | + openssl-dev \ |
| 54 | + pax-utils \ |
| 55 | + readline-dev \ |
| 56 | + sqlite-dev \ |
| 57 | + tcl-dev \ |
| 58 | + tk \ |
| 59 | + tk-dev \ |
| 60 | + xz-dev \ |
| 61 | + zlib-dev \ |
| 62 | +# add build deps before removing fetch deps in case there's overlap |
| 63 | + && apk del .fetch-deps \ |
| 64 | + \ |
| 65 | + && cd /usr/src/python \ |
| 66 | + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ |
| 67 | + && ./configure \ |
| 68 | + --build="$gnuArch" \ |
| 69 | + --enable-loadable-sqlite-extensions \ |
| 70 | + --enable-shared \ |
| 71 | + --with-system-expat \ |
| 72 | + --with-system-ffi \ |
| 73 | + --without-ensurepip \ |
| 74 | + && make -j "$(nproc)" \ |
| 75 | +# set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() |
| 76 | +# https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 |
| 77 | + EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ |
| 78 | + && make install \ |
| 79 | + \ |
| 80 | + && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ |
| 81 | + | tr ',' '\n' \ |
| 82 | + | sort -u \ |
| 83 | + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ |
| 84 | + | xargs -rt apk add --no-cache --virtual .python-rundeps \ |
| 85 | + && apk del .build-deps \ |
| 86 | + \ |
| 87 | + && find /usr/local -depth \ |
| 88 | + \( \ |
| 89 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 90 | + -o \ |
| 91 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 92 | + \) -exec rm -rf '{}' + \ |
| 93 | + && rm -rf /usr/src/python \ |
| 94 | + \ |
| 95 | + && python3 --version |
| 96 | + |
| 97 | +# make some useful symlinks that are expected to exist |
| 98 | +RUN cd /usr/local/bin \ |
| 99 | + && ln -s idle3 idle \ |
| 100 | + && ln -s pydoc3 pydoc \ |
| 101 | + && ln -s python3 python \ |
| 102 | + && ln -s python3-config python-config |
| 103 | + |
| 104 | +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" |
| 105 | +ENV PYTHON_PIP_VERSION 19.1.1 |
| 106 | + |
| 107 | +RUN set -ex; \ |
| 108 | + \ |
| 109 | + wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \ |
| 110 | + \ |
| 111 | + python get-pip.py \ |
| 112 | + --disable-pip-version-check \ |
| 113 | + --no-cache-dir \ |
| 114 | + "pip==$PYTHON_PIP_VERSION" \ |
| 115 | + ; \ |
| 116 | + pip --version; \ |
| 117 | + \ |
| 118 | + find /usr/local -depth \ |
| 119 | + \( \ |
| 120 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 121 | + -o \ |
| 122 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 123 | + \) -exec rm -rf '{}' +; \ |
| 124 | + rm -f get-pip.py |
| 125 | + |
| 126 | +CMD ["python3"] |
0 commit comments