fix cron after first run + add hc
docker-build / Build image (push) Failing after 6s

This commit is contained in:
2026-09-01 11:00:36 +07:00
parent 2875fc8334
commit 5646ecd6dd
8 changed files with 151 additions and 28 deletions
+12 -4
View File
@@ -1,14 +1,22 @@
#!/bin/sh
set +e
set -e
# crond runs jobs with a bare environment (HOME/PATH/SHELL only), so the
# container env is dumped here and sourced back by backup.sh on every run.
ENV_FILE=/tmp/container.env
export -p | grep -v -E "^export (PWD|SHLVL|OLDPWD|_)=" > "$ENV_FILE"
chmod 600 "$ENV_FILE"
# Create crontab in a writable location and set proper permissions
mkdir -p /tmp/crontabs
echo "${CRONTAB:-"0 * * * *"} /scripts/backup.sh >> /proc/1/fd/1 2>&1" > /tmp/crontabs/root
echo "${CRONTAB:-"0 * * * *"} /scripts/backup.sh --from-cron >> /proc/1/fd/1 2>&1" > /tmp/crontabs/root
chmod 644 /tmp/crontabs/root
# Run initial backup
/scripts/backup.sh
echo "[entrypoint] schedule: ${CRONTAB:-"0 * * * *"} (TZ=${TZ:-UTC})"
# Run initial backup (do not abort the container if it fails)
/scripts/backup.sh || echo "[entrypoint] initial backup failed, continuing to crond"
# Start crond in foreground with debug output
exec crond -f -c /tmp/crontabs -d 0