christianlempa-boilerplates/docker-compose/postgres/compose.yaml

46 lines
1.2 KiB
YAML
Raw Normal View History

2023-12-11 14:57:49 +01:00
---
services:
postgres:
image: docker.io/library/postgres:16.4
2024-03-26 11:59:45 +01:00
container_name: postgres
2023-12-11 14:57:49 +01:00
environment:
- POSTGRES_INITDB_ARGS=${POSTGRES_INITDB_ARGS---data-checksums}
- POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD-}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
- POSTGRES_DB=${POSTGRES_DB:-$POSTGRES_USER}
- TZ=${TZ:-UTC}
2023-12-11 14:57:49 +01:00
ports:
- 5432:5432
2024-03-02 16:48:26 +01:00
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U "${POSTGRES_USER:-postgres}"']
start_period: 30s
interval: 10s
timeout: 10s
retries: 5
2024-03-26 11:59:45 +01:00
# (Optional) When using custom network, see also
# https://docs.docker.com/compose/compose-file/compose-file-v3/#networks
#
2023-12-11 14:57:49 +01:00
# networks:
# - yournetwork
secrets:
- postgres_password
2023-12-11 14:57:49 +01:00
volumes:
- postgres_data:/var/lib/postgresql/data
2023-12-11 14:57:49 +01:00
restart: unless-stopped
2024-03-26 11:59:45 +01:00
# (Optional) When using custom network, see also
# https://docs.docker.com/compose/compose-file/compose-file-v3/#network-configuration-reference
#
# networks:
# yournetwork:
# external: true
secrets:
postgres_password:
file: secret.postgres_password.txt
volumes:
postgres_data:
driver: local