- Add monitor-db-stability.sh for automatic recovery - Improve PostgreSQL shutdown settings to prevent data loss - Add checkpoint and WAL settings for better persistence
89 lines
2.3 KiB
YAML
89 lines
2.3 KiB
YAML
version: "3.9"
|
|
|
|
services:
|
|
# PostgreSQL Database with persistent storage
|
|
db:
|
|
image: postgres:15-alpine
|
|
container_name: daarion-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: daarion
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
|
# Prevent data loss: ensure proper shutdown
|
|
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
- ./migrations:/docker-entrypoint-initdb.d:ro
|
|
- ./scripts:/scripts:ro
|
|
networks:
|
|
- dagi-network
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres -d daarion"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
# Add command to ensure proper shutdown and prevent data loss
|
|
command: postgres -c shared_buffers=256MB -c max_connections=200 -c checkpoint_timeout=15min -c wal_level=replica -c max_wal_size=1GB
|
|
|
|
# Automatic database backups
|
|
db-backup:
|
|
image: prodrigestivill/postgres-backup-local:latest
|
|
container_name: daarion-db-backup
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_HOST: db
|
|
POSTGRES_DB: daarion
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
|
SCHEDULE: "@every 12h"
|
|
BACKUP_KEEP_DAYS: 7
|
|
BACKUP_KEEP_WEEKS: 4
|
|
BACKUP_KEEP_MONTHS: 6
|
|
volumes:
|
|
- ./db_backups:/backups
|
|
depends_on:
|
|
- db
|
|
networks:
|
|
- dagi-network
|
|
|
|
# MinIO S3-compatible object storage for assets
|
|
minio:
|
|
image: minio/minio:latest
|
|
container_name: daarion-minio
|
|
restart: unless-stopped
|
|
command: server /data --console-address ":9001"
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-assets-admin}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-change-me-strong-password}
|
|
ports:
|
|
- "9000:9000" # S3 API
|
|
- "9001:9001" # Web console
|
|
volumes:
|
|
- minio_data:/data
|
|
networks:
|
|
- dagi-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
volumes:
|
|
pgdata:
|
|
driver: local
|
|
name: daarion_pgdata
|
|
minio_data:
|
|
driver: local
|
|
name: daarion_minio_data
|
|
|
|
networks:
|
|
dagi-network:
|
|
external: true
|
|
name: dagi-network
|
|
|