mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-01 05:51:16 +00:00
Start cron on db service start
init.d isn't run when docker containers are run so we need to modify the entrypoint. This commit makes the ugly choice of injecting the command in automatically in order to avoid the need to manually maintain the images entrypoint.
This commit is contained in:
parent
6c7fcb0dd1
commit
015d45ef99
3 changed files with 19 additions and 1 deletions
|
@ -175,7 +175,6 @@ Instructions for running BookWyrm in production:
|
|||
- Comment out the `command: certonly...` line in `docker-compose.yml`
|
||||
- Run docker-compose in the background with: `docker-compose up -d`
|
||||
- Initialize the database with: `./bw-dev initdb`
|
||||
- Set up schedule backups with cron that runs that `docker-compose exec db pg_dump -U <databasename>` and saves the backup to a safe location
|
||||
|
||||
Congrats! You did it, go to your domain and enjoy the fruits of your labors.
|
||||
|
||||
|
@ -205,3 +204,11 @@ There are three concepts in the book data model:
|
|||
|
||||
Whenever a user interacts with a book, they are interacting with a specific edition. Every work has a default edition, but the user can select other editions. Reviews aggregated for all editions of a work when you view an edition's page.
|
||||
|
||||
### Backups
|
||||
|
||||
Bookwyrm's db service dumps a backup copy of its database to its `/backups` directory daily at midnight UTC.
|
||||
Backups are named `backup__%Y-%m-%d.sql`.
|
||||
|
||||
You can copy backups from the backups volume to your host machine with `docker cp`:
|
||||
- Run `docker-compose ps` to confirm the db service's full name (it's probably `bookwyrm_db_1`.
|
||||
- Run `docker cp <container_name>:/backups <host machine path>
|
||||
|
|
|
@ -27,6 +27,8 @@ services:
|
|||
db:
|
||||
build: postgres-docker
|
||||
env_file: .env
|
||||
entrypoint: /bookwyrm-entrypoint.sh
|
||||
command: cron postgres
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- backups:/backups
|
||||
|
|
|
@ -8,3 +8,12 @@ RUN apt-get update && apt-get -y 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
|
||||
|
|
Loading…
Reference in a new issue