-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
103 lines (99 loc) · 3.17 KB
/
docker-compose.yml
File metadata and controls
103 lines (99 loc) · 3.17 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
services:
postgres_primary:
image: postgres:18-alpine
container_name: postgres_primary
hostname: postgres_primary
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
REPL_USER: ${REPL_USER}
REPL_PASSWORD: ${REPL_PASSWORD}
volumes:
- postgres_primary_data:/var/lib/postgresql/data
- ./log/postgres_primary:/var/log/postgresql
- ./primary/postgresql.conf:/etc/postgresql/postgresql.conf:ro
- ./primary/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
- ./primary/init-primary.sh:/docker-entrypoint-initdb.d/init-primary.sh:ro
command: ["postgres",
"-c", "config_file=/etc/postgresql/postgresql.conf",
"-c", "hba_file=/etc/postgresql/pg_hba.conf"]
networks:
- pg_net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "5432:5432"
postgres_replica_1:
image: postgres:18-alpine
container_name: postgres_replica_1
hostname: postgres_replica_1
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
REPL_USER: ${REPL_USER}
REPL_PASSWORD: ${REPL_PASSWORD}
PRIMARY_HOST: ${PRIMARY_HOST}
PRIMARY_PORT: ${PRIMARY_PORT}
depends_on:
postgres_primary:
condition: service_healthy
volumes:
- postgres_replica_1_data:/var/lib/postgresql/data
- ./log/postgres_replica_1:/var/log/postgresql
- ./replica/postgresql.conf:/etc/postgresql/postgresql.conf:ro
- ./replica/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
- ./replica/init-replica.sh:/init-replica.sh:ro
entrypoint: ["/bin/bash", "/init-replica.sh"]
networks:
- pg_net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -h localhost"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "5433:5432"
postgres_replica_2:
image: postgres:18-alpine
container_name: postgres_replica_2
hostname: postgres_replica_2
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
REPL_USER: ${REPL_USER}
REPL_PASSWORD: ${REPL_PASSWORD}
PRIMARY_HOST: ${PRIMARY_HOST}
PRIMARY_PORT: ${PRIMARY_PORT}
depends_on:
postgres_primary:
condition: service_healthy
volumes:
- postgres_replica_2_data:/var/lib/postgresql/data
- ./log/postgres_replica_2:/var/log/postgresql
- ./replica/postgresql.conf:/etc/postgresql/postgresql.conf:ro
- ./replica/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
- ./replica/init-replica.sh:/init-replica.sh:ro
entrypoint: ["/bin/bash", "/init-replica.sh"]
networks:
- pg_net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -h localhost"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "5434:5432"
networks:
pg_net:
driver: bridge
volumes:
postgres_primary_data:
postgres_replica_1_data:
postgres_replica_2_data: