use anchor for db service

This commit is contained in:
Philipp Rothmann 2023-03-28 23:50:41 +02:00
parent 637bf7c768
commit 0e9553be66
1 changed files with 4 additions and 25 deletions

View File

@ -65,7 +65,7 @@ services:
retries: 10 retries: 10
start_period: 10s start_period: 10s
db: db: &db
image: "mariadb:10.8" image: "mariadb:10.8"
volumes: volumes:
- "mariadb:/var/lib/mysql" - "mariadb:/var/lib/mysql"
@ -89,40 +89,19 @@ services:
labels: labels:
backupbot.backup: "true" backupbot.backup: "true"
backupbot.backup.path: "/tmp/dump.sql" backupbot.backup.path: "/tmp/dump.sql"
backupbot.backup.pre-hook: "sh -c 'mysqldump --single-transaction -u root -p\"$$(cat /run/secrets/db_root_password)\" wordpress > /tmp/dump.sql'" backupbot.backup.pre-hook: "sh -c 'mysqldump --single-transaction -u root -p\"$$(cat /run/secrets/db_root_password)\" $${MYSQL_DATABASE} > /tmp/dump.sql'"
backupbot.backup.post-hook: "rm -f /tmp/dump.sql" backupbot.backup.post-hook: "rm -f /tmp/dump.sql"
backupbot.restore: "true" backupbot.restore: "true"
backupbot.restore.post-hook: "sh -c 'mysql -u root -p\"$$(cat /run/secrets/db_root_password)\" wordpress < /tmp/dump.sql && rm -f /tmp/dump.sql'" backupbot.restore.post-hook: "sh -c 'mysql -u root -p\"$$(cat /run/secrets/db_root_password)\" $${MYSQL_DATABASE} < /tmp/dump.sql && rm -f /tmp/dump.sql'"
civicrm-db: civicrm-db:
image: "mariadb:10.8" <<: *db
volumes: volumes:
- "civicrm-db:/var/lib/mysql" - "civicrm-db:/var/lib/mysql"
environment: environment:
- MYSQL_DATABASE=civicrm - MYSQL_DATABASE=civicrm
- MYSQL_USER=civicrm - MYSQL_USER=civicrm
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password
secrets:
- db_password
- db_root_password
healthcheck:
test: ["CMD-SHELL", 'mysqladmin -p"$$(cat /run/secrets/db_root_password)" ping']
interval: 30s
timeout: 10s
retries: 10
start_period: 1m
deploy:
restart_policy:
condition: on-failure
labels:
backupbot.backup: "true"
backupbot.backup.path: "/tmp/dump.sql"
backupbot.backup.pre-hook: "sh -c 'mysqldump --single-transaction -u root -p\"$$(cat /run/secrets/db_root_password)\" civicrm > /tmp/dump.sql'"
backupbot.backup.post-hook: "rm -f /tmp/dump.sql"
backupbot.restore: "true"
backupbot.restore.post-hook: "sh -c 'mysql -u root -p\"$$(cat /run/secrets/db_root_password)\" civicrm < /tmp/dump.sql && rm -f /tmp/dump.sql'"
networks: networks:
proxy: proxy: