FROM python:3.12-slim
WORKDIR /app

# Deps first for layer caching — only re-runs when requirements.txt changes.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY app/ ./app/

# /app/data is the SQLite mount point (bind-mounted from ./data at runtime).
# The api runs as root deliberately: SQLite is written to a host bind mount, and
# a non-root uid can't write a host dir it doesn't own. To harden to non-root,
# also make the host ./data owned by that uid (or switch to a named volume).
RUN mkdir -p /app/data

EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
