Skip to content

Instantly share code, notes, and snippets.

@lorello
Created January 20, 2020 23:15
Show Gist options
  • Select an option

  • Save lorello/a6523d9377ed9a3d5416e84a72e64b16 to your computer and use it in GitHub Desktop.

Select an option

Save lorello/a6523d9377ed9a3d5416e84a72e64b16 to your computer and use it in GitHub Desktop.
Container with cron-like scheduling and healthcheck
FROM alpine
RUN set -x \
&& apk update && apk add ca-certificates curl \
&& curl -L https://github.com/odise/go-cron/releases/download/v0.0.7/go-cron-linux.gz | zcat > /usr/local/bin/go-cron \
&& chmod a+x /usr/local/bin/go-cron \
&& apk del ca-certificates
ENV SCHEDULE '@daily'
ENV HEALTHCHECK_PORT 8080
COPY backup.sh /bin/backup.sh
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["exec /usr/local/bin/go-cron -s \"$SCHEDULE\" -p \"$HEALTHCHECK_PORT\" -- /bin/backup.sh"]
HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f "http://localhost:$HEALTHCHECK_PORT/" || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment