60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
services:
|
|
<< service_name >>:
|
|
image: docker.io/library/postgres:18.3
|
|
restart: << restart_policy >>
|
|
container_name: << container_name >>
|
|
hostname: << container_hostname >>
|
|
environment:
|
|
- POSTGRES_INITDB_ARGS=<< postgres_initdb_args >>
|
|
<%- if postgres_host_auth_method %>
|
|
- POSTGRES_HOST_AUTH_METHOD=<< postgres_host_auth_method >>
|
|
<%- endif %>
|
|
- POSTGRES_USER=${POSTGRES_USER}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
|
- POSTGRES_DB=<< database_name >>
|
|
- TZ=<< container_timezone >>
|
|
<%- if network_mode == 'bridge' or network_mode == '' %>
|
|
networks:
|
|
<< network_name >>:
|
|
<%- endif %>
|
|
<%- if network_mode == 'bridge' or network_mode == '' %>
|
|
ports:
|
|
- "<< ports_postgres >>:5432"
|
|
<%- endif %>
|
|
volumes:
|
|
<%- if volume_mode == 'mount' %>
|
|
- << volume_mount_path >>:/var/lib/postgresql:rw
|
|
<%- else %>
|
|
- << service_name >>-data:/var/lib/postgresql
|
|
<%- endif %>
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
|
|
start_period: 30s
|
|
interval: 10s
|
|
timeout: 10s
|
|
retries: 5
|
|
|
|
<%- if volume_mode == 'local' %>
|
|
volumes:
|
|
<< service_name >>-data:
|
|
driver: local
|
|
<%- elif volume_mode == 'nfs' %>
|
|
volumes:
|
|
<< service_name >>-data:
|
|
driver: local
|
|
driver_opts:
|
|
type: nfs
|
|
o: addr=<< volume_nfs_server >>,<< volume_nfs_options >>
|
|
device: ":<< volume_nfs_path >>"
|
|
<%- endif %>
|
|
|
|
<%- if network_mode == 'bridge' or network_mode == '' %>
|
|
networks:
|
|
<< network_name >>:
|
|
<%- if network_external %>
|
|
external: true
|
|
<%- else %>
|
|
driver: bridge
|
|
<%- endif %>
|
|
<%- endif %>
|