# Use a lightweight Python base image
FROM python:3.10-slim

# Set working directory inside container
WORKDIR /app

# Copy dependency file first (for caching)
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .

# ===== Build-time arguments for secrets =====
ARG REDDIT_CLIENT_ID
ARG REDDIT_CLIENT_SECRET

# Environment variables (can be overridden at runtime)
ENV REDDIT_CLIENT_ID=$REDDIT_CLIENT_ID \
    REDDIT_CLIENT_SECRET=$REDDIT_CLIENT_SECRET \
    SUBREDDITS="worldnews" \
    POST_LIMIT=10 \
    COMMENT_LIMIT=10 \
    OUTPUT_DIR="/app/output"

# Create output directory inside container
RUN mkdir -p ${OUTPUT_DIR} && mkdir -p ${OUTPUT_DIR}/.meta

# Default command to run the scraper
CMD ["python", "app.py"]