news-digest: per-instance cron schedule via env

Hardcoded crontab → render at container start from
DIGEST_CRON_AM + DIGEST_CRON_PM. Defaults match the original
0800 / 2000 so existing deploys are no-ops.

scripts/add-digest-user.sh learns --am and --pm flags so each
teammate's stack can fire on their hours:

  scripts/add-digest-user.sh bob --am "0 6 * * *" --pm "0 17 * * *"
  scripts/add-digest-user.sh carol --pm "30 18 * * 1-5"   # weekdays only

Standard 5-field cron syntax; busybox crond honors the container's
\$TZ. Removed the now-unused stacks/news-digest/crontab file and
the matching COPY in the Dockerfile.
This commit is contained in:
vh
2026-04-28 14:29:55 -07:00
parent aeb5c18ca3
commit d552e289cb
6 changed files with 75 additions and 12 deletions
+6
View File
@@ -60,6 +60,12 @@ DIGEST_MINIFLUX_LOCAL_CATEGORY=Local
DIGEST_MINIFLUX_HEADLINES_HOURS=8
DIGEST_MINIFLUX_HEADLINES_MAX=15
# Cron schedule (standard 5-field). busybox crond honors $TZ above.
# Two fires per day by convention (morning / evening); change times
# per-user to match working hours.
DIGEST_CRON_AM=0 8 * * *
DIGEST_CRON_PM=0 20 * * *
# ── output dir on host (bind-mounted) ────────────────────────────────
# Separate from /opt/docker/conf/<stack>/ to keep generated content
# distinct from config. Owned by container UID; writes are atomic.
+4 -1
View File
@@ -40,7 +40,10 @@ COPY web.py /app/web.py
COPY templates /app/templates
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY run-digest.sh /usr/local/bin/run-digest.sh
COPY crontab /etc/crontabs/root
# /etc/crontabs/root is written by entrypoint.sh from
# DIGEST_CRON_AM/DIGEST_CRON_PM env at container start, so each
# per-user instance gets its own schedule. Image no longer ships a
# baked-in crontab.
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/run-digest.sh
# Sentinel + first-run output dir
+4
View File
@@ -48,6 +48,10 @@ services:
- DIGEST_MINIFLUX_LOCAL_CATEGORY=${DIGEST_MINIFLUX_LOCAL_CATEGORY:-Local}
- DIGEST_MINIFLUX_HEADLINES_HOURS=${DIGEST_MINIFLUX_HEADLINES_HOURS:-8}
- DIGEST_MINIFLUX_HEADLINES_MAX=${DIGEST_MINIFLUX_HEADLINES_MAX:-15}
# Per-instance cron schedule. Standard 5-field syntax. busybox
# crond honors $TZ. Defaults preserve the original 0800 / 2000.
- DIGEST_CRON_AM=${DIGEST_CRON_AM:-0 8 * * *}
- DIGEST_CRON_PM=${DIGEST_CRON_PM:-0 20 * * *}
volumes:
- ${NEWS_DIGEST_OUTPUT_DIR}:/output
networks:
-4
View File
@@ -1,4 +0,0 @@
# news-digest fires twice a day at 0800 and 2000 local (TZ from env).
# Output written atomically to /output/index.html — nginx serves it
# without restart.
0 8,20 * * * /usr/local/bin/run-digest.sh
+17 -4
View File
@@ -29,8 +29,21 @@ if [ ! -f /output/index.html ]; then
echo "[entrypoint] first run failed; cron will retry on schedule"
fi
# Tee crontab into the place busybox expects (already done in image
# via COPY) and run crond in foreground. -L /dev/stdout sends cron
# stdout/stderr to docker logs.
echo "[entrypoint] starting crond (fires per /etc/crontabs/root)"
# Render the crontab from env so each per-user instance can fire on
# its own schedule. Defaults match the original singleton (0800 / 2000
# local). Two separate vars (AM / PM) instead of one combined string
# so users can tweak one fire without re-deriving the other.
CRON_AM="${DIGEST_CRON_AM:-0 8 * * *}"
CRON_PM="${DIGEST_CRON_PM:-0 20 * * *}"
mkdir -p /etc/crontabs
{
echo "# news-digest cron — generated at container start from env."
echo "$CRON_AM /usr/local/bin/run-digest.sh"
echo "$CRON_PM /usr/local/bin/run-digest.sh"
} > /etc/crontabs/root
echo "[entrypoint] crontab:"
sed 's/^/ /' /etc/crontabs/root
# Foreground crond. -L /dev/stdout sends cron stdout/stderr to docker logs.
echo "[entrypoint] starting crond"
exec crond -f -L /dev/stdout -l 8