Python 2.7 on Ubuntu 18.04 with build tools and UTF-8 locales. No X11, no GUI stack.
49
# Python 2.7 on Ubuntu 18.04 (bionic).
#
# Sibling of py37-tools, for the other half of a 2-to-3 migration. Bionic is
# the last Ubuntu LTS carrying Python 2.7 in apt, and its glibc is 2.27: wheels
# resolved on a modern machine are often manylinux_2_28, which pip rejects here
# silently and surfaces much later as an unrelated dependency conflict. Build,
# download and test against the same distribution, interpreter and C library
# the deployment runs on.
#
# Included: python2.7 with headers, a virtualenv on PATH, a toolchain for
# building C extensions, and the common UTF-8 locales.
# Deliberately absent: X11, cairo, Qt and any other GUI stack.
FROM ubuntu:18.04
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# python2.7 + headers: build and install C extensions
# build-essential, binutils: the toolchain those extensions need
# wget: fetches get-pip below
# ca-certificates: TLS for pip
# locales: generated below
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
python2.7 \
python2.7-dev \
build-essential \
binutils \
wget \
ca-certificates \
locales; \
update-ca-certificates; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*
# UTF-8 locales for the languages an application is likely to format dates,
# numbers and currencies in. Add more with `locale-gen` at runtime if needed.
RUN set -eux; \
for loc in \
ca_ES cs_CZ de_DE en_GB en_US es_ES fr_FR hr_HR hu_HU it_IT \
lt_LT nl_NL pl_PL pt_PT ru_RU sk_SK zh_CN; do \
sed -i "s/^# ${loc}.UTF-8/${loc}.UTF-8/" /etc/locale.gen; \
done; \
locale-gen; \
update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
# A docker exec is not a login shell and does not read /etc/default/locale, so
# the values are set here as well. They also keep the interactive interpreter
# from choking on non-ASCII output, which Python 2 is particularly prone to.
ENV LANG=en_US.UTF-8 \
LANGUAGE= \
LC_ALL=en_US.UTF-8
# Bionic dropped pip for 2.7 from its repositories, so it comes from the
# pypa bootstrap, which still publishes the last release that supports it.
RUN set -eux; \
wget -q https://bootstrap.pypa.io/pip/2.7/get-pip.py; \
python2.7 get-pip.py; \
rm get-pip.py; \
python2.7 -m pip install --no-cache-dir virtualenv
# A virtualenv rather than the system interpreter: pip upgrades here cannot
# break apt-managed packages, and `python` resolves to 2.7 without a suffix.
RUN set -eux; \
virtualenv -p /usr/bin/python2.7 /venv; \
/venv/bin/pip install --no-cache-dir --upgrade "setuptools<45" wheel
ENV PATH=/venv/bin:$PATH
WORKDIR /work
CMD ["python"]
``
Content type
Image
Digest
sha256:99ecf0cd5…
Size
160.3 MB
Last updated
8 days ago
docker pull justdevzero/py27-tools