# cs.money worker: headful Chromium (nodriver) under a virtual display, with noVNC
# so you can open a browser into the container and solve a Cloudflare challenge by hand
# if one ever appears. Build context is the repo root (see docker-compose.yml).
FROM python:3.13-slim

# chromium + a virtual X display + VNC bridge + the fonts/libs Chromium needs.
RUN apt-get update && apt-get install -y --no-install-recommends \
        chromium \
        xvfb \
        x11vnc \
        novnc \
        websockify \
        ca-certificates \
        fonts-liberation \
        dumb-init \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY worker/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY worker/worker.py worker/entrypoint.sh ./
RUN chmod +x entrypoint.sh

ENV BROWSER_PATH=/usr/bin/chromium \
    CHROME_NO_SANDBOX=1 \
    DISPLAY=:99 \
    SOLVE_SECONDS=45 \
    PYTHONUNBUFFERED=1


# noVNC web UI (browse http://localhost:6080/vnc.html to watch / solve a challenge).
EXPOSE 6080

# dumb-init reaps the Xvfb/x11vnc/websockify children cleanly.
ENTRYPOINT ["dumb-init", "--", "./entrypoint.sh"]
