|
1 | 1 | # TODO: Find out whether it possible to use "faster" base Python image |
2 | | -FROM python:3.9.7-slim-buster as python-base |
| 2 | +FROM python:3.10.0-slim-bullseye as python-base |
3 | 3 |
|
4 | 4 | LABEL maintainer="Igor Davydenko <iam@igordavydenko.com>" |
5 | | -LABEL description="Add poetry, pre-commit, and other dev-tools to official Python slim Docker image." |
6 | | - |
7 | | -# Ensure to use latest system versions |
8 | | -RUN apt update -qq && apt upgrade -y && apt autoremove -y |
9 | | - |
10 | | -# Global poetry setup |
11 | | -ENV POETRY_HOME "/opt/poetry" |
12 | | -ENV POETRY_NO_INTERACTION "1" |
13 | | -ENV PATH "${POETRY_HOME}/bin:${PATH}" |
14 | | - |
15 | | -# Install poetry at one stage |
16 | | -FROM python-base as poetry-base |
17 | | - |
18 | | -ENV POETRY_VERSION "1.1.10" |
19 | | -RUN apt install -y build-essential curl |
20 | | -RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/install-poetry.py | python |
21 | | -RUN poetry --version |
22 | | - |
23 | | -# Install dev tools at another stage |
24 | | -FROM python-base as development-base |
25 | | - |
26 | | -# Additonal applications to install |
27 | | -ENV ADDITIONAL_APPS \ |
28 | | - curl \ |
29 | | - g++ \ |
30 | | - gcc \ |
31 | | - gettext \ |
32 | | - git \ |
33 | | - locales \ |
34 | | - locales-all \ |
35 | | - make \ |
36 | | - nano \ |
37 | | - openssh-client \ |
38 | | - rsync |
39 | | -RUN apt install -y ${ADDITIONAL_APPS} && apt autoremove -y |
40 | | - |
| 5 | +LABEL description="Add poetry, pre-commit, and other dev-tools installed via pipx to official Python slim Docker image." |
| 6 | + |
| 7 | +# Install additional dev dependencies and ensure to use latest system versions |
| 8 | +RUN apt-get update -qq \ |
| 9 | + && apt-get upgrade -y \ |
| 10 | + && apt-get autoremove -y \ |
| 11 | + && apt-get install --no-install-recommends -y \ |
| 12 | + curl \ |
| 13 | + g++ \ |
| 14 | + gcc \ |
| 15 | + gettext \ |
| 16 | + git \ |
| 17 | + locales \ |
| 18 | + locales-all \ |
| 19 | + make \ |
| 20 | + nano \ |
| 21 | + openssh-client \ |
| 22 | + rsync \ |
| 23 | + && apt-get clean \ |
| 24 | + && rm -rf /var/lib/apt/lists/* \ |
| 25 | + && apt-get autoremove -y |
| 26 | + |
| 27 | +# Update path to include `/root/.local/bin` |
| 28 | +ENV PATH="/root/.local/bin:${PATH}" |
| 29 | + |
| 30 | +# Update pip to latest version, install pipx & virtualen into user directory, |
| 31 | +# and install additional dev-tools via pipx into `~/.local` |
| 32 | +# |
41 | 33 | # To check latest versions, |
42 | 34 | # |
43 | 35 | # ```bash |
44 | | -# pip-latest-release pip pre-commit tox virtualenv |
| 36 | +# pip-latest-release pip pipx poetry pre-commit tox virtualenv |
45 | 37 | # ``` |
46 | | -ENV PIP_VERSION "21.2.4" |
47 | | -ENV PRE_COMMIT_VERSION "2.15.0" |
48 | | -ENV TOX_VERSION "3.24.4" |
49 | | -ENV VIRTUALENV_VERSION "20.8.1" |
50 | | - |
51 | | -RUN pip install \ |
52 | | - pip==${PIP_VERSION} \ |
53 | | - pre-commit==${PRE_COMMIT_VERSION} \ |
54 | | - tox==${TOX_VERSION} \ |
55 | | - virtualenv==${VIRTUALENV_VERSION} |
56 | | - |
57 | | -# Copy poetry from previous stage |
58 | | -COPY --from=poetry-base ${POETRY_HOME} ${POETRY_HOME} |
| 38 | +ENV PIP_VERSION="21.3.1" |
| 39 | +ENV PIPX_VERSION="0.16.4" |
| 40 | +ENV POETRY_VERSION="1.1.11" |
| 41 | +ENV PRE_COMMIT_VERSION="2.15.0" |
| 42 | +ENV TOX_VERSION="3.24.4" |
| 43 | +ENV VIRTUALENV_VERSION="20.10.0" |
| 44 | + |
| 45 | +RUN python3 -m pip install --no-cache-dir pip==${PIP_VERSION} \ |
| 46 | + && python3 -m pip install --no-cache-dir --user pipx==${PIPX_VERSION} virtualenv==${VIRTUALENV_VERSION} \ |
| 47 | + && python3 -m pipx install --pip-args=--no-cache-dir poetry==${POETRY_VERSION} \ |
| 48 | + && python3 -m pipx install --pip-args=--no-cache-dir pre-commit==${PRE_COMMIT_VERSION} \ |
| 49 | + && python3 -m pipx install --pip-args=--no-cache-dir tox==${TOX_VERSION} |
59 | 50 |
|
60 | 51 | WORKDIR /app |
61 | 52 | CMD ["python3"] |
0 commit comments