moviewyrm/postgres-docker/Dockerfile
Joel Bradshaw 2e9574d53c Add database to filename, don't install recommends
Cron comes with just a metric ton of recommended dependencies including
mariadb-common which is just a bunch of unneccessary weight. Just
install what's necessary for cron.
2021-12-28 14:18:57 -08:00

20 lines
972 B
Docker

FROM postgres:13.0
# crontab
RUN mkdir /backups
COPY ./backup.sh /backups
COPY ./weed.sh /backups
COPY ./cronfile /etc/cron.d/cronfile
RUN apt-get update && apt-get -y --no-install-recommends install cron
RUN chmod 0644 /etc/cron.d/cronfile
RUN crontab /etc/cron.d/cronfile
RUN touch /var/log/cron.log
# 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