FROM python:3.12-slim

COPY . /app
WORKDIR /app

ENV DATA_FOLDER=/app/data
ENV PYTHONUNBUFFERED=1

RUN mkdir -p "$DATA_FOLDER" \
    && python -m pip install --upgrade pip \
    && python -m pip install --no-cache-dir -r requirements.txt

EXPOSE 8000

# Keep one worker: service lifecycle state is local to the process.
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:8000", "main:app"]
