FROM python:3.12-slim

WORKDIR /app

# Install system dependencies including Node.js for yt-dlp JavaScript runtime
RUN apt update && apt install -y \
    weasyprint \
    libcairo2 \
    pango1.0-tools \
    libpango-1.0-0 \
    libgobject-2.0-0 \
    ffmpeg \
    ca-certificates \
    curl \
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt install -y nodejs \
    && update-ca-certificates \
    && apt clean \
    && rm -rf /var/lib/apt/lists/*

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

COPY . .

EXPOSE 8000
