All checks were successful
cc-ci/testme cc-ci: success
Move the postgres and clickhouse backup/restore hook logic out of inline compose labels into dedicated pg_backup.sh / clickhouse_backup.sh config scripts (the pattern other recipes use), and trim the verbose explanatory comments down to the essential rationale, now living in the scripts.
121 lines
4.0 KiB
YAML
121 lines
4.0 KiB
YAML
---
|
|
version: "3.8"
|
|
|
|
services:
|
|
app:
|
|
image: plausible/analytics:v2.0.0
|
|
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
|
|
depends_on:
|
|
- db
|
|
- plausible_events_db
|
|
environment:
|
|
- BASE_URL=https://$DOMAIN
|
|
- SECRET_KEY_BASE
|
|
- DATABASE_URL=postgres://plausible:plausible@${STACK_NAME}_db:5432/plausible
|
|
- CLICKHOUSE_DATABASE_URL=http://${STACK_NAME}_plausible_events_db:8123/plausible_events_db
|
|
- SMTP_HOST_ADDR
|
|
- MAILER_EMAIL
|
|
- SMTP_HOST_PORT
|
|
- SMTP_USER_NAME
|
|
- SMTP_USER_PWD
|
|
- SMTP_HOST_SSL_ENABLED
|
|
- DISABLE_REGISTRATION
|
|
- DISABLE_AUTH
|
|
networks:
|
|
- proxy
|
|
- internal
|
|
deploy:
|
|
restart_policy:
|
|
# `any`, not `on-failure`: a restore disrupts postgres under the app and Erlang then
|
|
# shuts down gracefully (exit 0), which on-failure treats as done and never restarts.
|
|
condition: any
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8000"
|
|
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
|
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
|
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
|
- coop-cloud.${STACK_NAME}.version=3.1.0+v2.0.0
|
|
db:
|
|
image: pgautoupgrade/pgautoupgrade:18-alpine
|
|
volumes:
|
|
- db-data:/var/lib/postgresql/data
|
|
environment:
|
|
# pin legacy PGDATA so the existing cluster on the volume is upgraded in place, not re-init'd
|
|
- PGDATA=/var/lib/postgresql/data
|
|
- POSTGRES_USER=plausible
|
|
- POSTGRES_PASSWORD=plausible
|
|
- POSTGRES_DB=plausible
|
|
networks:
|
|
- internal
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U plausible -d plausible"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 60
|
|
configs:
|
|
- source: pg_backup
|
|
target: /pg_backup.sh
|
|
mode: 0555
|
|
deploy:
|
|
labels:
|
|
backupbot.backup: "true"
|
|
backupbot.backup.volumes.db-data.path: "postgres.dump.gz"
|
|
backupbot.backup.pre-hook: "/pg_backup.sh backup"
|
|
backupbot.backup.post-hook: "/pg_backup.sh backup_cleanup"
|
|
backupbot.restore: "true"
|
|
backupbot.restore.post-hook: "/pg_backup.sh restore"
|
|
|
|
plausible_events_db:
|
|
image: clickhouse/clickhouse-server:23.4.2.11-alpine
|
|
volumes:
|
|
- event-data:/var/lib/clickhouse
|
|
entrypoint: /custom-entrypoint.sh
|
|
configs:
|
|
- source: clickhouse-config
|
|
target: /etc/clickhouse-server/config.d/logging.xml
|
|
- source: clickhouse-user-config
|
|
target: /etc/clickhouse-server/users.d/clickhouse-user-config.xml
|
|
- source: clickhouse_entrypoint
|
|
target: /custom-entrypoint.sh
|
|
mode: 0555
|
|
- source: clickhouse_backup
|
|
target: /clickhouse_backup.sh
|
|
mode: 0555
|
|
networks:
|
|
- internal
|
|
deploy:
|
|
labels:
|
|
backupbot.backup: "true"
|
|
backupbot.backup.volumes.event-data.path: "backup/events"
|
|
backupbot.backup.pre-hook: "/clickhouse_backup.sh backup"
|
|
backupbot.backup.post-hook: "/clickhouse_backup.sh backup_cleanup"
|
|
backupbot.restore: "true"
|
|
backupbot.restore.post-hook: "/clickhouse_backup.sh restore"
|
|
|
|
volumes:
|
|
db-data:
|
|
event-data:
|
|
|
|
networks:
|
|
proxy:
|
|
external: true
|
|
internal:
|
|
|
|
configs:
|
|
clickhouse-config:
|
|
name: ${STACK_NAME}_clickhouse_config_${CLICKHOUSE_CONF_VERSION}
|
|
file: clickhouse-config.xml
|
|
clickhouse-user-config:
|
|
name: ${STACK_NAME}_clickhouse_user_config_${CLICKHOUSE_USER_CONF_VERSION}
|
|
file: clickhouse-user-config.xml
|
|
clickhouse_entrypoint:
|
|
name: ${STACK_NAME}_clickhouse_entrypoint_${CLICKHOUSE_ENTRYPOINT_VERSION}
|
|
file: entrypoint.clickhouse.sh
|
|
pg_backup:
|
|
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
|
|
file: pg_backup.sh
|
|
clickhouse_backup:
|
|
name: ${STACK_NAME}_clickhouse_backup_${CLICKHOUSE_BACKUP_SCRIPT_VERSION}
|
|
file: clickhouse_backup.sh
|