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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Changelog", this file is a reverse-chronological list of merged pull requests.

## Open PR's

- [PR-156](https://github.com/itk-dev/devops_itkdev-docker/pull/156) - 2026-10-08 -
Python template: install dev tools as a `[dependency-groups]` group so
`uv sync` picks them up, and keep the venv in `/opt/venv` on `PATH` so the
`./:/app` bind mount does not hide it
- [PR-155](https://github.com/itk-dev/devops_itkdev-docker/pull/155) - 2026-10-05 -
Python template: select the services to lint and test by the label
`dk.itkdev.language: python` instead of `dk.itkdev.python: "true"`
Expand Down
12 changes: 9 additions & 3 deletions templates/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ FROM python:3.12-slim-bookworm AS base
# with pip; this project keeps uv because it has a uv.lock.
COPY --from=ghcr.io/astral-sh/uv:0.12.8 /uv /uvx /bin/

# The venv lives outside /app so the docker compose bind mount of ./:/app does
# not hide it, and its bin directory is on PATH so the workflows can call
# `pytest`, `ruff` and `basedpyright` directly.
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
PYTHONUNBUFFERED=1 \
UV_PROJECT_ENVIRONMENT=/opt/venv \
PATH="/opt/venv/bin:$PATH"

# Non-root user matching the k8s securityContext (runAsUser/runAsGroup: 1000).
RUN groupadd --gid 1000 app \
Expand All @@ -23,11 +28,12 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
RUN chown app:app /app
RUN mkdir /opt/venv \
&& chown app:app /app /opt/venv

USER app

# Copy project files as the app user so /app/.venv (created by `uv sync` below)
# Copy project files as the app user so /opt/venv (created by `uv sync` below)
# is owned by UID 1000 from the start.
COPY --chown=app:app pyproject.toml uv.lock ./
COPY --chown=app:app src/ ./src/
Expand Down
4 changes: 3 additions & 1 deletion templates/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ dependencies = [
"uvicorn[standard]>=0.30.0",
]

[project.optional-dependencies]
# A dependency group, not an optional extra: `uv sync` installs the `dev` group by
# default (and `--no-dev` skips it), but installs extras only with `--extra`.
[dependency-groups]
dev = [
"ruff>=0.9.0",
"pytest>=8.0",
Expand Down
Loading