# Ghost Node — Dockerfile
# Builds a container for worker.py (FastAPI + Playwright + scraper engine).
# Usage: docker compose up  (see docker-compose.yml)

FROM python:3.11-slim

# System deps for Playwright Chromium
RUN apt-get update && apt-get install -y \
    wget curl gnupg ca-certificates \
    libglib2.0-0 libnss3 libnspr4 libdbus-1-3 \
    libatk1.0-0 libatk-bridge2.0-0 libcups2 \
    libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
    libxfixes3 libxrandr2 libgbm1 libasound2 \
    fonts-liberation libpango-1.0-0 libpangocairo-1.0-0 \
    --no-install-recommends && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python deps first (cached layer)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Install Playwright + Chromium browser
RUN playwright install chromium && playwright install-deps chromium

# Copy application files
COPY worker.py models.py database.py dashboard.html ./

# Copy pre-built Next.js static output if it exists (optional)
COPY frontend/out ./frontend/out

EXPOSE 7000

ENV PYTHONUNBUFFERED=1

CMD ["python", "worker.py"]
