From 25b9aeafcecde018313a9d05e0800bc49f6a472e Mon Sep 17 00:00:00 2001 From: Dan O'Huiginn Date: Tue, 17 Nov 2026 15:54:22 +0100 Subject: [PATCH 1/3] build: a Dockerfile for running the pipeline in a container A uv + Python 3.14 image with the locked, non-dev dependencies installed and the project on PATH. Dependencies sit in their own layer, so a source change does not reinstall them. The image carries .git, so get_git_version can stamp provenance; build it from a full clone, not a git worktree. .dockerignore keeps .env (and any *.env) out of the image: supply it at runtime. It also drops host venvs, caches and the exact-patch .python-version pin, which the base image's uv may not fetch. --- .dockerignore | 23 +++++++++++++++++++++++ Dockerfile | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..40c24c3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +# Claude worktrees and other local tooling state. +.claude/ + +# A host venv, at any depth, must not shadow the one built inside the image. +**/.venv/ + +# Exact-patch pin (e.g. 3.14.5) a base image's uv may not fetch; requires-python (>=3.14,<3.15) +# is satisfied by any 3.14.x, so let uv use the base image's own. +.python-version + +# Secrets: supply .env at runtime, never bake it into the image. `*.env` matches any env file +# but not the `*.env.example` templates, which stay. +.env +**/*.env + +# Caches / build noise. +**/__pycache__/ +*.pyc +.mypy_cache/ +.pytest_cache/ +.ruff_cache/ +.cache/ +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0ccee1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# syntax=docker/dockerfile:1.19 +# Build from a full clone, not a git worktree: a worktree's .git is a file pointing outside the +# build context, and the image needs the repository for git provenance (utils.get_git_version). + +FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim + +WORKDIR /app + +# The rasterio/GDAL wheels vendor GDAL but still link libexpat, which the slim image omits. +# safe.directory lets git read /app when the container runs as a user other than its owner. +RUN apt-get update \ + && apt-get install -y --no-install-recommends git libexpat1 \ + && rm -rf /var/lib/apt/lists/* \ + && git config --system --add safe.directory /app + +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen --no-install-project --no-dev + +COPY --exclude=.git . . +RUN uv sync --frozen --no-dev + +# .git in its own last layer, so a commit that changes no source rebuilds only this layer. +COPY .git .git + +ENV PATH="/app/.venv/bin:${PATH}" From 4e8d1de1ce164697bc17dc17082ecb0603d8e02a Mon Sep 17 00:00:00 2001 From: Dan O'Huiginn Date: Tue, 17 Nov 2026 20:10:54 +0100 Subject: [PATCH 2/3] utils: get_git_version names the commit on a detached HEAD A container built from a detached checkout (as CI checks out a pull request) raised TypeError from repo.active_branch. Same guard as fork #53. --- jdluc/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdluc/utils.py b/jdluc/utils.py index 61e7ca0..20ff959 100644 --- a/jdluc/utils.py +++ b/jdluc/utils.py @@ -75,6 +75,9 @@ def save_remote_url_to_local_path( @functools.cache def get_git_version(default_branch_name: str = "main") -> str: repo = git.Repo(__file__, search_parent_directories=True) + # NB: a detached HEAD, as CI checks out a pull request, has no branch to name + if repo.head.is_detached: + return repo.head.commit.hexsha[:8] if (branch_name := repo.active_branch.name) == default_branch_name: return f"{branch_name:s}-{repo.head.commit.hexsha[:8]:s}" else: From ccd2994d823911c3544ed94efb0954bf71dd2e4a Mon Sep 17 00:00:00 2001 From: Dan O'Huiginn Date: Wed, 18 Nov 2026 09:33:48 +0100 Subject: [PATCH 3/3] build: a debian trixie base with uv copied in, per review - debian:trixie-slim and uv pinned by multi-arch digest - uv-managed Python under /opt/python, readable by a non-root user; .python-version no longer ignored, so the image runs dev's exact pin - ca-certificates for HTTPS from the slim base - fail the build if .git has no HEAD (e.g. built from a git worktree) - comments dropped; apt packages one per line --- .dockerignore | 4 ---- Dockerfile | 24 ++++++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.dockerignore b/.dockerignore index 40c24c3..13b20f7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,10 +4,6 @@ # A host venv, at any depth, must not shadow the one built inside the image. **/.venv/ -# Exact-patch pin (e.g. 3.14.5) a base image's uv may not fetch; requires-python (>=3.14,<3.15) -# is satisfied by any 3.14.x, so let uv use the base image's own. -.python-version - # Secrets: supply .env at runtime, never bake it into the image. `*.env` matches any env file # but not the `*.env.example` templates, which stay. .env diff --git a/Dockerfile b/Dockerfile index 0ccee1b..529a909 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,29 @@ # syntax=docker/dockerfile:1.19 -# Build from a full clone, not a git worktree: a worktree's .git is a file pointing outside the -# build context, and the image needs the repository for git provenance (utils.get_git_version). +FROM debian:trixie-slim@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2 -FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim +COPY --from=ghcr.io/astral-sh/uv:0.13.9@sha256:d3b601f0c7b118bc1753febf7c41cc80981df678445e0254284eecf84db79a7d /uv /uvx /bin/ + +ENV UV_PYTHON_INSTALL_DIR=/opt/python WORKDIR /app -# The rasterio/GDAL wheels vendor GDAL but still link libexpat, which the slim image omits. -# safe.directory lets git read /app when the container runs as a user other than its owner. -RUN apt-get update \ - && apt-get install -y --no-install-recommends git libexpat1 \ +RUN : \ + && apt-get update \ + && apt-get install --no-install-recommends --yes \ + ca-certificates \ + git \ + libexpat1 \ && rm -rf /var/lib/apt/lists/* \ - && git config --system --add safe.directory /app + && git config --system --add safe.directory /app \ + && : -COPY pyproject.toml uv.lock ./ +COPY pyproject.toml uv.lock .python-version ./ RUN uv sync --frozen --no-install-project --no-dev COPY --exclude=.git . . RUN uv sync --frozen --no-dev -# .git in its own last layer, so a commit that changes no source rebuilds only this layer. COPY .git .git +RUN git rev-parse --verify HEAD ENV PATH="/app/.venv/bin:${PATH}"