# syntax=docker/dockerfile:1
FROM python:3.12-slim

# Install uv (fast Python package manager).
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    UV_COMPILE_BYTECODE=1 \
    UV_LINK_MODE=copy

WORKDIR /app

# Install dependencies first for better layer caching.
COPY pyproject.toml ./
COPY uv.lock* ./
RUN uv sync --no-dev

# Copy the application.
COPY . .
RUN chmod +x entrypoint.sh

# If sqlite3 is used
VOLUME /data
EXPOSE 8000

# Seeds perms/roles/superuser (idempotent, no-op if already present), then runs the API server.
ENTRYPOINT ["./entrypoint.sh"]
