From 5562a4956cb8dc41e4654134de9175e49cf9b521 Mon Sep 17 00:00:00 2001 From: Jason Wright Date: Tue, 17 Nov 2026 09:08:38 -0700 Subject: [PATCH] build(docker): install runtime deps from uv.lock The image installed the wheel with `uv pip install`, which resolved its dependencies fresh from PyPI and ignored uv.lock, so the image could ship package versions pip-audit never checked. Export the locked runtime deps with hashes in the build stage (`uv export --locked`, which fails the build on a stale lock) and install them with --require-hashes, then install the wheel with --no-deps. Pin the uv base image to 0.13.9-python3.13-trixie-slim for repeatable builds, and add the docker ecosystem to Dependabot so it bumps the pin. Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 7 +++++++ Dockerfile | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 55c48b0..da2749b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,3 +11,10 @@ updates: schedule: interval: weekly open-pull-requests-limit: 5 + + # Bumps the pinned uv/Python base image in the Dockerfile. + - package-ecosystem: docker + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 5 diff --git a/Dockerfile b/Dockerfile index dae6f3d..a25706e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,28 @@ +# The uv version is pinned so builds are repeatable; Dependabot (docker ecosystem) bumps it. # ---- build stage: produce a wheel with uv's build backend ---- -FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim AS build +FROM ghcr.io/astral-sh/uv:0.13.9-python3.13-trixie-slim AS build WORKDIR /src COPY . . -RUN uv build --wheel --out-dir /dist +# The wheel, plus the runtime deps pinned (with hashes) exactly as uv.lock has them. --locked fails the +# build if uv.lock is out of date with pyproject.toml (--frozen would export the stale lock silently). +RUN uv build --wheel --out-dir /dist \ + && uv export --locked --no-dev --no-emit-project -o /dist/requirements.txt # ---- runtime stage: install the wheel that was just built ---- -FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim +FROM ghcr.io/astral-sh/uv:0.13.9-python3.13-trixie-slim RUN groupadd --system quantumsolver \ && useradd --system --gid quantumsolver --no-create-home quantumsolver WORKDIR /app -COPY --from=build /dist/*.whl /tmp/ -# Installs the quantumsolver package plus its runtime deps (Flask, qiskit, gunicorn, ...). -RUN uv pip install --system --no-cache /tmp/*.whl && rm /tmp/*.whl +COPY --from=build /dist/ /tmp/dist/ +# Runtime deps (Flask, qiskit, gunicorn, ...) at the versions in uv.lock, then the quantumsolver wheel +# alone, so nothing is resolved fresh from PyPI and the image matches what pip-audit checked. +RUN uv pip install --system --no-cache --require-hashes -r /tmp/dist/requirements.txt \ + && uv pip install --system --no-cache --no-deps /tmp/dist/*.whl \ + && rm -rf /tmp/dist COPY --chown=quantumsolver:quantumsolver gunicorn.conf.py .