diff --git a/cronjob/Dockerfile b/cronjob/Dockerfile index 0457a04..ce767d2 100644 --- a/cronjob/Dockerfile +++ b/cronjob/Dockerfile @@ -1,9 +1,11 @@ ARG COMMAND_VERSION=latest -FROM ghcr.io/daniele-athome/immich-carddav-sync:${COMMAND_VERSION} +FROM ghcr.io/daniele-athome/immich-carddav-sync:${COMMAND_VERSION} as runtime -RUN apt-get update && apt-get install --no-install-recommends -y cron +RUN apt-get update && apt-get install --no-install-recommends -y gettext-base cron -COPY cronjob.sh /etc/cron.daily/immich-carddav-sync -RUN chmod 0755 /etc/cron.daily/immich-carddav-sync +COPY crontab.tmpl /app/crontab.tmpl -ENTRYPOINT ["cron", "-f"] +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/cronjob/cronjob.sh b/cronjob/cronjob.sh deleted file mode 100644 index 1295970..0000000 --- a/cronjob/cronjob.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -python -m immich_carddav_sync.main diff --git a/cronjob/crontab.tmpl b/cronjob/crontab.tmpl new file mode 100644 index 0000000..dd9285a --- /dev/null +++ b/cronjob/crontab.tmpl @@ -0,0 +1,9 @@ +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * user-name command to be executed +${CRON_EXPRESSION} root cd / && PATH=/app/.venv/bin python -m immich_carddav_sync.main >/proc/1/fd/1 2>/proc/1/fd/2 diff --git a/cronjob/entrypoint.sh b/cronjob/entrypoint.sh new file mode 100644 index 0000000..9507315 --- /dev/null +++ b/cronjob/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +env >> /etc/environment + +envsubst < /app/crontab.tmpl >/etc/cron.d/immich-carddav-sync + +exec cron -f