FROM python:3.11-slim

# Playwright/Firefox runtime deps (GTK, X11, fonts, dbus)
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgtk-3-0 libdbus-glib-1-2 libx11-xcb1 libxt6 libasound2 \
    libxcomposite1 libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 \
    libcairo2 libnss3 libxss1 fonts-liberation ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

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

# Pre-download the Camoufox browser so first request is fast
RUN python -m camoufox fetch

COPY app.py .
COPY static/ static/

EXPOSE 8000
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]