# Use Python 3.11 as base image
FROM python:3.11-slim

# Install system dependencies required for browser automation and other tools
RUN apt-get update && apt-get install -y \
    wget \
    curl \
    git \
    build-essential \
    chromium \
    chromium-driver \
    fonts-liberation \
    libappindicator3-1 \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libcups2 \
    libdbus-1-3 \
    libdrm2 \
    libgbm1 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libx11-xcb1 \
    libxcomposite1 \
    libxdamage1 \
    libxrandr2 \
    xdg-utils \
    && rm -rf /var/lib/apt/lists/*

# Install uv for fast Python package management
RUN pip install --no-cache-dir uv

# Set working directory
WORKDIR /app

# Copy dependency files
COPY pyproject.toml uv.lock ./

# Install dependencies using uv
RUN uv sync --frozen

# Copy application code
COPY app.py ./

# Create docs directory (user should mount their own config.yaml and docs)
RUN mkdir -p docs

# Set Python path to use uv's virtual environment
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1

# Set Chrome/Chromium path for browser automation
ENV CHROMIUM_PATH=/usr/bin/chromium
ENV CHROME_PATH=/usr/bin/chromium

# Default command (user should override with their own config.yaml)
CMD ["python", "app.py"]
