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

# libmagic1 : bibliothèque système requise par python-magic (détection MIME
# par analyse binaire, étape 3 du module fichiers).
RUN apt-get update \
    && apt-get install -y --no-install-recommends libmagic1 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 5000

# Gunicorn multi-worker en production (Bloc 1 - C6 : workers = 2*CPU + 1).
# GUNICORN_CMD_ARGS permet de surcharger la config sans reconstruire l'image.
CMD ["gunicorn", "--workers=4", "--worker-class=gthread", "--threads=2", \
     "--bind=0.0.0.0:5000", "app:app"]
