diff --git a/src/Dockerfile b/src/Dockerfile index 7f711da..d452acf 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,11 +1,14 @@ FROM restic/restic:0.9.6 -RUN apk update && apk add python3 dcron mariadb-client postgresql-client +RUN apk update && apk add ca-certificates python3 dcron mariadb-client postgresql-client && rm -rf /var/cache/apk/* ADD . /restic-compose-backup WORKDIR /restic-compose-backup RUN pip3 install -U pip setuptools wheel && pip3 install -e . ENV XDG_CACHE_HOME=/cache -ENTRYPOINT [] -CMD ["./entrypoint.sh"] +VOLUME ["/usr/local/share/ca-certificates"] + +ENTRYPOINT ["./entrypoint.sh"] + +CMD [] diff --git a/src/entrypoint.sh b/src/entrypoint.sh index a223b7b..bfc8c0d 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,11 +1,38 @@ #!/bin/sh -# Dump all env vars so we can source them in cron jobs -printenv | sed 's/^\(.*\)$/export \1/g' > /env.sh +set -e -# Write crontab -rcb crontab > crontab +setup_cacerts(){ -# start cron in the foreground -crontab crontab -crond -f + update-ca-certificates +} + +dump_env(){ + + # Dump all env vars so we can source them in cron jobs + printenv | sed 's/^\(.*\)$/export \1/g' > /env.sh +} + +setup_crontab(){ + + # Write crontab + rcb crontab > crontab + + # start cron in the foreground + crontab crontab + crond -f +} + +start_app(){ + + setup_cacerts + + if [ "$1" = '' ]; then + dump_env + setup_crontab + else + exec "$@" + fi +} + +start_app "$@"