2026-08-17 13:40:09 +03:00

60 lines
1.8 KiB
YAML

# Postgres metadata database — production single-node profile.
#
# Not published to the host: only in-cluster services reach it over the
# internal network. Credentials are required (no defaults). Tuned conservatively
# for a single-node reference deployment; adjust to the host's memory.
#
# Backup/restore is handled out of band by backup.sh (RPO target 15 min,
# documented RTO under 2 h). Included by compose.yaml.
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
stop_grace_period: 1m
environment:
POSTGRES_USER: ${POSTGRES_USER:?set POSTGRES_USER in .env}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
POSTGRES_DB: ${POSTGRES_DB:?set POSTGRES_DB in .env}
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C --data-checksums"
command:
- postgres
- -c
- max_connections=${POSTGRES_MAX_CONNECTIONS:-200}
- -c
- shared_buffers=${POSTGRES_SHARED_BUFFERS:-512MB}
- -c
- effective_cache_size=${POSTGRES_EFFECTIVE_CACHE_SIZE:-1536MB}
- -c
- wal_compression=on
- -c
- checkpoint_completion_target=0.9
- -c
- log_min_duration_statement=1000
volumes:
- lawsynth_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
security_opt:
- no-new-privileges:true
logging:
driver: json-file
options: { max-size: "10m", max-file: "5" }
deploy:
resources:
limits:
cpus: "${POSTGRES_CPU_LIMIT:-2}"
memory: ${POSTGRES_MEMORY_LIMIT:-2g}
networks:
- lawsynth
networks:
lawsynth:
volumes:
lawsynth_pgdata: