Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Claude worktrees and other local tooling state.
.claude/

# A host venv, at any depth, must not shadow the one built inside the image.
**/.venv/

# 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
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# syntax=docker/dockerfile:1.19
FROM debian:trixie-slim@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2

COPY --from=ghcr.io/astral-sh/uv:0.13.9@sha256:d3b601f0c7b118bc1753febf7c41cc80981df678445e0254284eecf84db79a7d /uv /uvx /bin/

ENV UV_PYTHON_INSTALL_DIR=/opt/python

WORKDIR /app

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 \
&& :

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

COPY .git .git
RUN git rev-parse --verify HEAD

ENV PATH="/app/.venv/bin:${PATH}"
3 changes: 3 additions & 0 deletions jdluc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading