FROM python:3.12-slim

WORKDIR /app

# Pillow needs these to build/run; python:3.12-slim's manylinux wheels cover
# most of it, but libjpeg/zlib runtime libs are still needed at import time.
RUN apt-get update && apt-get install -y --no-install-recommends \
    libjpeg62-turbo \
    zlib1g \
    && rm -rf /var/lib/apt/lists/*

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

COPY . .

RUN mkdir -p instance uploads

EXPOSE 5000

# instance/ (sqlite db) and uploads/ (receipt photos) should be mounted as
# volumes - see docker-compose.yml - so they survive a container rebuild.
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--timeout", "60", "run:app"]
