51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
services:
|
|
db:
|
|
image: postgres:10
|
|
container_name: postgres_prod_trade
|
|
restart: always
|
|
env_file: .env
|
|
environment:
|
|
- TZ=${TZ}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
|
- POSTGRES_USER=${POSTGRES_USER}
|
|
- POSTGRES_DB=${POSTGRES_DB}
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- ./pgdata:/var/lib/postgresql/data
|
|
# Read-only config mounts for security
|
|
- ./config/postgresql.conf:/etc/postgresql/postgresql.conf:ro
|
|
- ./config/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
|
|
# Syncs container time with host system time
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- /etc/timezone:/etc/timezone:ro
|
|
# Use configuration files from ./config instead of ./pgdata
|
|
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
backup_cron:
|
|
image: prodrigestivill/postgres-backup-local:10
|
|
container_name: postgres_backup_service_trade
|
|
restart: always
|
|
env_file: .env
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
environment:
|
|
- TZ=${TZ}
|
|
- POSTGRES_HOST=db
|
|
- POSTGRES_DB=${POSTGRES_DB}
|
|
- POSTGRES_USER=${POSTGRES_USER}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
|
- SCHEDULE=${BACKUP_SCHEDULE}
|
|
- BACKUP_KEEP_DAYS=${BACKUP_RETENTION_DAYS}
|
|
- BACKUP_DIR=/backups
|
|
volumes:
|
|
- ./backups:/backups
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- /etc/timezone:/etc/timezone:ro
|