# ─────────────────────────────────────────────
# HuggingFace Daily Paper RSS — EasyPanel-ready Dockerfile
# ─────────────────────────────────────────────
# Single container that:
#   1. Generates RSS feeds on startup
#   2. Serves them via HTTP (port 8080, CORS enabled)
#   3. Auto-refreshes every 24h (background thread)
#
# Deploy on EasyPanel: health check + persistent volume
# ─────────────────────────────────────────────

FROM python:3.11-slim

WORKDIR /app

# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

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

# App code
COPY parser.py rss_generator.py run.py server.py ./

# Volume for persistent feed output
VOLUME ["/data"]

# Health check — verify feed.xml exists (generated on startup)
HEALTHCHECK --interval=60s --timeout=10s --start-period=30s --retries=3 \
    CMD python -c "import os; exit(0 if os.path.exists('/data/feed.xml') else 1)"

EXPOSE 8080

ENTRYPOINT ["python", "server.py"]
CMD ["--dir", "/data", "--port", "8080", "--refresh", "24"]
