FROM python:3.12-slim

COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /bin/uv

# Fuseau horaire : toutes les dates/heures du domaine sont naïves et
# interprétées en heure locale Europe/Paris (règles « 22h », « journée »…).
RUN apt-get update \
    && apt-get install -y --no-install-recommends tzdata \
    && rm -rf /var/lib/apt/lists/*

ENV TZ=Europe/Paris \
    UV_LINK_MODE=copy \
    UV_COMPILE_BYTECODE=1 \
    UV_PROJECT_ENVIRONMENT=/app/.venv \
    PATH="/app/.venv/bin:$PATH" \
    # Défaut 30s : trop court pour certains gros paquets (reportlab ->
    # charset-normalizer) sur un runner CI à bande passante limitée, d'où
    # les échecs "network timeout" en intégration.
    UV_HTTP_TIMEOUT=180

WORKDIR /app

# Couche de dépendances (cache tant que pyproject ne change pas).
COPY pyproject.toml ./
RUN uv sync --no-install-project

# Code applicatif.
COPY . .
RUN uv sync

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