Skip to content

Commit 3d8ad5e

Browse files
build: Install poetry, pre-commit, and tox via pipx (#16)
As well as bump base image to `python:3.10.0-slim-bullseye`.
1 parent 12ddc7b commit 3d8ad5e

2 files changed

Lines changed: 59 additions & 59 deletions

File tree

Dockerfile

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,52 @@
11
# 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
33

44
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+
#
4133
# To check latest versions,
4234
#
4335
# ```bash
44-
# pip-latest-release pip pre-commit tox virtualenv
36+
# pip-latest-release pip pipx poetry pre-commit tox virtualenv
4537
# ```
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}
5950

6051
WORKDIR /app
6152
CMD ["python3"]

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/playpauseandstop/docker-python.svg)
44
![Docker Pulls](https://img.shields.io/docker/pulls/playpauseandstop/docker-python.svg)
55

6-
Add poetry, pre-commit, and other dev-tools to official Python slim Docker
7-
image.
6+
Add poetry, pre-commit, and other dev-tools installed via pipx to official
7+
Python slim Docker image.
88

99
## Usage
1010

1111
```dockerfile
12-
FROM playpauseandstop/docker-python:4.3.0
12+
FROM playpauseandstop/docker-python:5.0.0
1313
```
1414

1515
### Included dev-tools
1616

17-
- [pip](https://pip.pypa.io) 21.1.1
18-
- [poetry](https://python-poetry.org) 1.1.6
19-
- [pre-commit](https://pre-commit.com) 2.12.1
20-
- [tox](https://tox.readthedocs.io/) 3.23.0
21-
- [virtualenv](https://virtualenv.pypa.io) 20.4.4
17+
- [pip](https://pip.pypa.io) 21.3.1
18+
- [pipx](https://pypa.github.io/pipx/) 0.16.4
19+
- [poetry](https://python-poetry.org) 1.1.11
20+
- [pre-commit](https://pre-commit.com) 2.15.0
21+
- [tox](https://tox.readthedocs.io/) 3.24.2
22+
- [virtualenv](https://virtualenv.pypa.io) 20.10.0
2223
- [curl](https://curl.haxx.se) 7.64.0
2324
- [gcc & g++](https://gcc.gnu.org) 8.3.0
2425
- [git](https://git-scm.com) 2.20.1
@@ -37,6 +38,14 @@ other versions supported as well.
3738

3839
List of supported Python versions are (`<PY_VERSION>` -> base Docker image)
3940

41+
#### 5.0.0
42+
43+
- `py310` -> `python:3.10.0-slim-bullseye`
44+
- `py39` -> `python:3.9.8-slim-bullseye`
45+
- `py38` -> `python:3.8.12-slim-bullseye`
46+
- `py37` -> `python:3.7.12-slim-bullseye`
47+
- `py36` -> `python:3.6.15-slim-bullseye`
48+
4049
#### 4.3.0
4150

4251
- `py39` -> `python:3.9.5-slim-buster`

0 commit comments

Comments
 (0)