mirror of
https://github.com/ChristianLempa/boilerplates.git
synced 2024-11-22 08:13:18 +01:00
Merge pull request #165 from cschug/improve_compose_postgres
Improve Docker Compose file of PostgreSQL
This commit is contained in:
commit
72bed1c361
1
docker-compose/postgres/.gitignore
vendored
Normal file
1
docker-compose/postgres/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
secret.*
|
@ -1,24 +1,45 @@
|
||||
---
|
||||
# (Optional) when using custom network
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.2
|
||||
container_name: postgres
|
||||
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}
|
||||
ports:
|
||||
- 5432:5432
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U "${POSTGRES_USER:-postgres}"']
|
||||
start_period: 30s
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
# (Optional) When using custom network, see also
|
||||
# https://docs.docker.com/compose/compose-file/compose-file-v3/#networks
|
||||
#
|
||||
# networks:
|
||||
# - yournetwork
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
|
||||
# (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:
|
||||
services:
|
||||
postgres:
|
||||
# (Recommended) replace "latest" with specific version
|
||||
image: postgres:latest
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
# (Optional) when creating a new database
|
||||
# - POSTGRES_DB=${POSTGRES_DB}
|
||||
ports:
|
||||
- 5432:5432
|
||||
# (Optional) when using custom network
|
||||
# networks:
|
||||
# - yournetwork
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
postgres_data:
|
||||
driver: local
|
||||
|
Loading…
Reference in New Issue
Block a user