# news-digest worker — twice-daily curated briefing generator.
#
# Runs cron internally (alpine's busybox crond) and a one-shot
# digest.py per fire. Bind-mounted /output is shared with the
# news-digest-web nginx container that serves the HTML.

FROM python:3.12-alpine

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1

# tzdata so $TZ works for cron + datetime; tini so signals propagate cleanly.
RUN apk add --no-cache tzdata tini bash

RUN pip install --no-cache-dir requests jinja2

WORKDIR /app
COPY digest.py /app/digest.py
COPY templates /app/templates
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY crontab /etc/crontabs/root
RUN chmod +x /usr/local/bin/entrypoint.sh

# Sentinel + first-run output dir
VOLUME /output

ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"]
