flywheel/python

By flywheel

Updated 4 days ago

Python base images

Image
API Management
Data Science

10K+

flywheel/python

Python base image for Flywheel projects, coming with

  • the flywheel:flywheel user - just set USER flywheel in the last layer
  • the /var/metrics folder for storing multiprocessing metrics - just set ENV PROMETHEUS_MULTIPROC_DIR=/var/metrics
  • the following basic utilities for both build- and run-time:
  • in addition, the -build variant contains git and ssh

Tags

CI pipelines on the main branch push the following tagging scheme to DockerHub:

  • flywheel/python:{PYTHON_VER}-{BASE_IMAGE} - the recommended prod base image
  • flywheel/python:{PYTHON_VER}-{BASE_IMAGE}-build - build variant with git and ssh

Available PYTHON_VERs: 3.12 (default), 3.11, 3.10, 3.9
Available BASE_IMAGEs: alpine (default), debian (bookworm)

The default 3.12-alpine is also tagged as latest, e.g.:

  • flywheel/python:latest === :3.12-alpine
  • flywheel/python:build === :3.12-alpine-build

Commit-specific tags are available for improved reproducibility, e.g.:

  • flywheel/python:3.12-debian-d34db33f

Usage

Create a .dockerignore to keep the context limited to the files added:

# exclude everything
**
# include files needed
!myproj
!pyproject.toml
!README.md
!requirements.txt
# re-exclude cruft
**/__pycache__

Create a Dockerfile:

FROM flywheel/python:3.12-alpine AS base
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
WORKDIR /src
COPY requirements.txt ./
RUN uv pip install -rrequirements.txt
CMD ["my-app"]
EXPOSE 8000

FROM base AS dev
COPY requirements-dev.txt ./
RUN uv pip install -rrequirements-dev.txt
COPY . .
RUN python -m compileall -bqj0 . && \
    fd -epy -E__init__.py -xrm . && \
    uv pip install --no-deps -e.

FROM base AS prod
COPY --from=dev /src .
RUN uv pip install --no-deps -e.
USER flywheel

License

MIT

Repository

flywheel-io/tools/img/python

Docker Pull Command

docker pull flywheel/python