Created
January 20, 2020 23:15
-
-
Save lorello/a6523d9377ed9a3d5416e84a72e64b16 to your computer and use it in GitHub Desktop.
Container with cron-like scheduling and healthcheck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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