# syntax=docker/dockerfile:1
#
# Debian Trixie is the current stable base; Bookworm is superseded. Python 3.13
# is Trixie's default interpreter and satisfies every dependency below. The uv
# image is pinned to a specific release and manifest digest so a rebuild does
# not silently move to a new toolchain.
FROM ghcr.io/astral-sh/uv:0.13.5-python3.13-trixie-slim@sha256:331fbb158258608b9391e802305a9a2c9e42d689435c1d98706647122a122ab0

WORKDIR /app

ENV UV_COMPILE_BYTECODE=1 \
    UV_LINK_MODE=copy \
    PYTHONUNBUFFERED=1 \
    PATH="/app/.venv/bin:${PATH}"

# Resolve wheels through the homelab caching proxy when CI passes PROXY_URL.
# Unset, this is uv's own default index, so the layer is unchanged for anyone
# building outside the LAN.
ARG PROXY_URL=
ENV UV_DEFAULT_INDEX=${PROXY_URL:+$PROXY_URL/pypi/simple}https://pypi.org/simple

# Dependencies first, so changing only src/ or scripts/ reuses this layer.
# README.md is present because pyproject.toml declares it as the project readme.
COPY pyproject.toml README.md ./
RUN uv venv && uv pip install --no-cache -r pyproject.toml

COPY src/ ./src/
COPY scripts/ ./scripts/

EXPOSE 8080

# Run from source with the project root on sys.path. The package is a src-layout
# namespace package; installing it into site-packages is unnecessary for a
# single-service image.
CMD ["python", "-m", "src.brain_dump.server"]
