2020-10-28 22:56:25 +00:00
|
|
|
FROM postgres:latest
|
|
|
|
|
|
|
|
# crontab
|
|
|
|
RUN mkdir /backups
|
2020-10-28 23:10:50 +00:00
|
|
|
COPY ./backup.sh /backups
|
2021-03-09 05:16:34 +00:00
|
|
|
COPY ./weed.sh /backups
|
2020-10-28 23:10:50 +00:00
|
|
|
COPY ./cronfile /etc/cron.d/cronfile
|
2020-10-28 22:56:25 +00:00
|
|
|
RUN apt-get update && apt-get -y install cron
|
2020-10-28 23:10:50 +00:00
|
|
|
RUN chmod 0644 /etc/cron.d/cronfile
|
|
|
|
RUN crontab /etc/cron.d/cronfile
|
2020-10-28 22:56:25 +00:00
|
|
|
RUN touch /var/log/cron.log
|
2021-03-09 05:09:54 +00:00
|
|
|
|
|
|
|
# The postgres image's entrypoint expects the docker command to only contain flags to
|
|
|
|
# pass postgres. It runs the entrypoint twice, the second times as the postgres user.
|
|
|
|
# We need to start the cron service the first time it runs, when it's still being run
|
|
|
|
# as the root user. We're going to add a check that looks at the first argument and
|
|
|
|
# if it's 'cron', starts the service and then removes that argument.
|
|
|
|
RUN awk '$0 ~ /^\t_main "\$@"$/ { print "\tif [[ $1 == cron ]]; then\n\t\tservice cron start\n\t\tshift\n\tfi" }{ print }' docker-entrypoint.sh > bookwyrm-entrypoint.sh
|
|
|
|
RUN chown postgres /bookwyrm-entrypoint.sh
|
|
|
|
RUN chmod u=rwx,go=r /bookwyrm-entrypoint.sh
|