Skip to content

Commit

Permalink
Cronjob image with configurable cron expression
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-athome committed Aug 27, 2023
1 parent bc8301f commit 5490b49
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
12 changes: 7 additions & 5 deletions cronjob/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 0 additions & 3 deletions cronjob/cronjob.sh

This file was deleted.

9 changes: 9 additions & 0 deletions cronjob/crontab.tmpl
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions cronjob/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

env >> /etc/environment

envsubst < /app/crontab.tmpl >/etc/cron.d/immich-carddav-sync

exec cron -f

0 comments on commit 5490b49

Please sign in to comment.