1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
x-node: &node
build:
context: ../..
dockerfile: Dockerfile
tags:
- pg_auto_failover:tutorial
volumes:
- /var/lib/postgres
environment:
PGDATA: /var/lib/postgres/pgaf
PGUSER: tutorial
PGDATABASE: tutorial
PG_AUTOCTL_HBA_LAN: true
PG_AUTOCTL_AUTH_METHOD: "trust"
PG_AUTOCTL_SSL_SELF_SIGNED: true
PG_AUTOCTL_MONITOR: "postgresql://autoctl_node@monitor/pg_auto_failover"
expose:
- 5432
services:
app:
build:
context: .
dockerfile: Dockerfile.app
environment:
PGUSER: tutorial
PGDATABASE: tutorial
PGHOST: node1,node2
PGPORT: 5432
PGAPPNAME: tutorial
PGSSLMODE: require
PGTARGETSESSIONATTRS: read-write
monitor:
image: pg_auto_failover:tutorial
volumes:
- /var/lib/postgres
environment:
PGDATA: /var/lib/postgres/pgaf
PG_AUTOCTL_SSL_SELF_SIGNED: true
expose:
- 5432
command: |
pg_autoctl create monitor --auth trust --run
node1:
<<: *node
hostname: node1
command: |
pg_autoctl create postgres --name node1 --run
node2:
<<: *node
hostname: node2
command: |
pg_autoctl create postgres --name node2 --run
node3:
<<: *node
hostname: node3
command: |
pg_autoctl create postgres --name node3 --run
|