Skip to content

build: a Dockerfile for running the pipeline in a container - #41

Open
danohu wants to merge 3 commits into
mainfrom
dockerfile
Open

danohu wants to merge 3 commits into
mainfrom
dockerfile

Conversation

@danohu

@danohu danohu commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Adds a Dockerfile and .dockerignore, so the pipeline can run in a container on whatever infrastructure people use. The Dockerfile has no entrypoint: pass the command when you run it.

What's in it

  • Built on ghcr.io/astral-sh/uv:python3.14-bookworm-slim, which matches requires-python. It installs the locked, non-dev dependencies (uv sync --frozen --no-dev) in a layer of their own, so a change to the code doesn't reinstall them. The project's venv goes on PATH.
  • git and libexpat1 come from apt: the rasterio/GDAL wheels link libexpat, which the slim image leaves out.
  • .git is copied in a final layer of its own, so utils.get_git_version can stamp provenance on outputs. That's why the image must be built from a full clone, not a git worktree. safe.directory lets git read the repository when the container runs as a non-root user.
  • .dockerignore keeps .env and *.env out of the image: supply configuration at runtime, for example with docker run --env-file .env. It also excludes host venvs, caches and the exact-patch .python-version pin, which the base image's uv may not be able to fetch.

Notes

  • Needs BuildKit, for COPY --exclude; the # syntax= line selects a recent enough frontend.
  • On a detached HEAD, for example a CI checkout of a pull request, the current get_git_version raises at runtime. That is separate from this PR.

Test plan

  • docker build -t luc . from a full clone
  • docker run --rm --env-file .env luc python -c "import jdluc"

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.
@danohu
danohu requested a review from jeffseif November 17, 2026 15:05

@jeffseif jeffseif left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good addition! Just a few suggestions and comments

Comment thread Dockerfile Resolved
Comment thread Dockerfile Resolved
Comment thread Dockerfile Resolved
Comment thread Dockerfile Resolved
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.
- 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

@jeffseif jeffseif left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants