-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
218 lines (208 loc) · 5.11 KB
/
docker-compose.yml
File metadata and controls
218 lines (208 loc) · 5.11 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
version: '3.8'
x-postgres-common:
&postgres-common
image: ${REGISTRY}postgres:16.8
user: postgres
services:
app:
image: app
profiles:
- app
build:
context: .
dockerfile: Dockerfile
user: app
volumes:
- ./apps/:/app/apps
- ./packages/:/app/packages
- ./bin/:/app/bin
- ./package.json:/app/package.json
- ./.env:/app/.env
networks:
- app-network
postgresdb:
image: ${REGISTRY}alpine
profiles: ['dbs']
depends_on:
- postgresdb-master
- postgresdb-replica
networks:
- app-network
postgresdb-master:
<<: *postgres-common
ports:
- "127.0.0.1:5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_DB: main
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: "scram-sha-256\nhost replication all 0.0.0.0/0 scram-sha-256"
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
command: |
postgres
-c max_connections=2000
-c wal_level=replica
-c synchronous_commit=on
-c statement_timeout=10s
-c shared_buffers=256MB
volumes:
- ./docker-compose-postgresql-init-replication.sql:/docker-entrypoint-initdb.d/docker-compose-postgresql-init-replication.sql
networks:
- app-network
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
postgresdb-replica:
<<: *postgres-common
ports:
- "127.0.0.1:5433:5432"
environment:
PGUSER: replicator
PGPASSWORD: replicator_password
command: |
bash -c "
if [ ! -f /var/lib/postgresql/initialized ]; then
pg_basebackup --pgdata=/var/lib/postgresql/data -R --slot=replication_slot --host=postgresdb-master --port=5432
chmod -R 0700 /var/lib/postgresql/data
touch /var/lib/postgresql/initialized
fi
postgres -c max_connections=2000 -c statement_timeout=10s -c shared_buffers=256MB
"
networks:
- app-network
depends_on:
postgresdb-master:
condition: service_healthy
redis:
image: ${REGISTRY}redis:6.2
ports:
- "127.0.0.1:6379:6379"
networks:
- app-network
command: ["redis-server", "--databases", "64"]
nats:
image: ${REGISTRY}nats:2.12-alpine
ports:
- "127.0.0.1:4222:4222"
- "127.0.0.1:8080:8080"
- "127.0.0.1:8222:8222"
environment:
MESSAGING_CONFIG: ${MESSAGING_CONFIG}
networks:
- app-network
extra_hosts:
- "host.docker.internal:host-gateway"
entrypoint: ["/nats-entrypoint.sh"]
command: ["-c", "/etc/nats/nats.conf"]
volumes:
- ./nats.conf:/etc/nats/nats.conf:ro
- ./nats-entrypoint.sh:/nats-entrypoint.sh:ro
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
interval: 10s
timeout: 5s
retries: 5
valkey-cluster:
image: ${REGISTRY}alpine
profiles: ['dbs']
depends_on:
- valkey-node-3
- valkey-node-2
- valkey-node-1
- valkey-cluster-creator
valkey-cluster-creator:
command:
- valkey-cli
- --cluster
- create
- localhost:7001
- localhost:7002
- localhost:7003
- --cluster-yes
- --cluster-replicas
- '0'
depends_on:
valkey-node-1:
condition: service_healthy
valkey-node-2:
condition: service_healthy
valkey-node-3:
condition: service_healthy
image: ${REGISTRY}valkey/valkey:8.0.2
network_mode: host
valkey-node-1:
command:
- valkey-server
- /valkey/valkey.conf
- --port
- '7001'
healthcheck:
interval: 10s
retries: 3
test: [ "CMD", "valkey-cli", "-p", "7001", "-c", "ping" ]
timeout: 5s
image: ${REGISTRY}valkey/valkey:8.0.2
network_mode: host
configs:
- source: valkey.conf
target: /valkey/valkey.conf
ports:
- 7001:7000
volumes:
- valkey-data-1:/data
valkey-node-2:
command:
- valkey-server
- /valkey/valkey.conf
- --port
- '7002'
healthcheck:
interval: 10s
retries: 3
test: ["CMD", "valkey-cli", "-p", "7002", "-c", "ping"]
timeout: 5s
image: ${REGISTRY}valkey/valkey:8.0.2
network_mode: host
configs:
- source: valkey.conf
target: /valkey/valkey.conf
ports:
- 7002:7000
volumes:
- valkey-data-2:/data
valkey-node-3:
command:
- valkey-server
- /valkey/valkey.conf
- --port
- '7003'
healthcheck:
interval: 10s
retries: 3
test: ["CMD", "valkey-cli", "-p", "7003", "-c", "ping"]
timeout: 5s
image: ${REGISTRY}valkey/valkey:8.0.2
network_mode: host
configs:
- source: valkey.conf
target: /valkey/valkey.conf
ports:
- 7003:7000
volumes:
- valkey-data-3:/data
networks:
app-network:
driver: bridge
volumes:
valkey-data-1: {}
valkey-data-2: {}
valkey-data-3: {}
configs:
valkey.conf:
content: |
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes