#!/usr/bin/env bash # entrypoint.sh — news-digest worker startup. # # Strategy: # 1. If /output is empty, run digest.py once at start so the page # isn't blank while waiting for the next cron tick. # 2. Start busybox crond in foreground so the container stays up. # # All env vars are inherited from compose, including TZ which busybox # crond honors when computing fire times. set -e mkdir -p /output # Sync static frontend assets from /app/templates → /output. The web # container serves /output as static; the assets are baked into the # image but the bind-mounted /output otherwise wouldn't pick up # CSS/JS updates on rebuild without a manual copy. for asset in style.css app.js favicon.svg; do if [ -f "/app/templates/$asset" ]; then cp -f "/app/templates/$asset" "/output/$asset" fi done if [ ! -f /output/index.html ]; then echo "[entrypoint] no /output/index.html yet — running first digest" /usr/local/bin/run-digest.sh || \ 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)" exec crond -f -L /dev/stdout -l 8