fix: build the image on Python 3.14
Build and Push Image / Unit tests (push) Successful in 1m2s
Build and Push Image / Build and push image (push) Skipped

The image build failed on master:

    ERROR: Ignored the following versions that require a different python
    version: 4.19.0 Requires-Python >=3.11
    ERROR: Could not find a version that satisfies the requirement
    pymongo==4.19.0

The base image was `python:3.10` but the pinned pymongo 4.19 needs Python
>= 3.11. The image is now `python:3.14-slim` — the current stable release,
so it is not carrying the CVEs fixed in 3.11, 3.12 and 3.13.

All the runtime dependencies ship a cp314 wheel (pymongo included), so no
compiler toolchain is needed. The old apt-get line installed
libsasl2-dev, python-dev-is-python3, libldap2-dev and libssl-dev for
packages that are no longer in the dependency list, so it is gone and the
image is smaller.

The build now asserts the interpreter version, so a base image change that
breaks the pinned requirements fails the build with a clear message rather
than a pip resolution error.
This commit is contained in:
2026-11-09 11:23:22 +10:00
parent 78b3b10131
commit 9d3ce1d2c4
+15 -4
View File
@@ -1,11 +1,22 @@
FROM python:3.10 AS beer_base_image
FROM python:3.14-slim AS beer_base_image
WORKDIR /beer_data
COPY requirements.txt .
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libsasl2-dev python-dev-is-python3 libldap2-dev libssl-dev
# The runtime dependencies (flask, flask-wtf, waitress, pymongo, requests) all
# ship as wheels for 3.14, so no compiler toolchain is needed. The old image
# installed libsasl2-dev, python-dev-is-python3, libldap2-dev and libssl-dev
# for packages that are no longer in the dependency list.
#
# The Python version matters:
# - pymongo 4.19 requires Python >= 3.11, so the base image could not stay
# on 3.10 once the requirements were pinned.
# - 3.14 is the current stable release, so the image is not carrying the
# CVEs fixed in 3.11, 3.12 and 3.13.
RUN pip install --upgrade pip --no-cache-dir
RUN pip install --upgrade pip
RUN pip --default-timeout=1000 install --no-cache-dir -r requirements.txt
RUN pip --default-timeout=1000 install -r requirements.txt
# Fail the build if the interpreter is not the one the image claims.
RUN python -c "import sys; assert sys.version_info[:2] == (3, 14), sys.version"