FROM python:3.12-slim

WORKDIR /app

# System deps for Playwright's Chromium (playwright install-deps covers the
# actual browser dependencies below; git/curl are just useful in-container
# for debugging import/dependency issues without rebuilding).
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    && rm -rf /var/lib/apt/lists/*

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

# Installs the Chromium binary + the OS-level libraries it needs
# (fonts, codecs, etc.) — must run after playwright is pip-installed.
RUN playwright install --with-deps chromium

COPY . .

EXPOSE 5000

CMD ["gunicorn", "app:app", "-w", "4", "-b", "0.0.0.0:5000"]
