68 lines
1.8 KiB
YAML
68 lines
1.8 KiB
YAML
version: '3.8'
|
|
|
|
x-postgres-env: &postgres-env
|
|
POSTGRES_DB: bonfire_db
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
|
|
services:
|
|
app:
|
|
environment:
|
|
<<: *postgres-env
|
|
POSTGRES_HOST: ${STACK_NAME}_db
|
|
secrets:
|
|
- postgres_password
|
|
|
|
db:
|
|
image: ${DB_DOCKER_IMAGE:-ghcr.io/baosystems/postgis}:${DB_DOCKER_VERSION:-17-3.5}
|
|
command: >
|
|
postgres
|
|
-c max_connections=200
|
|
-c shared_buffers=${DB_MEMORY_LIMIT}MB
|
|
# -c shared_preload_libraries='pg_stat_statements'
|
|
# -c statement_timeout=1800000
|
|
# -c pg_stat_statements.track=all
|
|
#entrypoint: ['tail', '-f', '/dev/null'] # uncomment when the Postgres DB is corrupted and won't start
|
|
volumes:
|
|
- db-data:/var/lib/postgresql/data
|
|
- type: tmpfs
|
|
target: /dev/shm
|
|
tmpfs:
|
|
size: 1000000000
|
|
# about 1 GB in bytes
|
|
tmpfs:
|
|
- /tmp:size=${DB_MEMORY_LIMIT}M^
|
|
networks:
|
|
- internal
|
|
environment:
|
|
<<: *postgres-env
|
|
secrets:
|
|
- postgres_password
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready", "-U", "postgres"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
deploy:
|
|
labels:
|
|
backupbot.backup: ${ENABLE_BACKUPS:-true}
|
|
backupbot.backup.pre-hook: "/pg_backup.sh backup"
|
|
backupbot.backup.volumes.db-data.path: "backup.sql"
|
|
backupbot.restore.post-hook: '/pg_backup.sh restore'
|
|
configs:
|
|
- source: pg_backup
|
|
target: /pg_backup.sh
|
|
mode: 0555
|
|
|
|
volumes:
|
|
db-data:
|
|
|
|
configs:
|
|
pg_backup:
|
|
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
|
|
file: pg_backup.sh
|
|
|
|
secrets:
|
|
postgres_password:
|
|
external: true
|
|
name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION:-v1} |