forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-compose.beginners.yml
328 lines (318 loc) · 7.5 KB
/
docker-compose.beginners.yml
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
version: "2.1"
services:
consul1:
image: hashicorp/consul:latest
hostname: "consul1"
ports:
- "8400:8400"
- "8500:8500"
- "8600:8600"
command: "agent -server -bootstrap-expect 3 -ui -disable-host-node-id -client 0.0.0.0"
consul2:
image: hashicorp/consul:latest
hostname: "consul2"
expose:
- "8400"
- "8500"
- "8600"
command: "agent -server -retry-join consul1 -disable-host-node-id"
depends_on:
- consul1
consul3:
image: hashicorp/consul:latest
hostname: "consul3"
expose:
- "8400"
- "8500"
- "8600"
command: "agent -server -retry-join consul1 -disable-host-node-id"
depends_on:
- consul1
# This is a convenience container to quickly test vitess against an external database.
# In practice you will point Vitess to your existing database and migrate to a Vitess managed cluster.
external_db_host:
build:
context: ./external_db/mysql
dockerfile: Dockerfile
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-pass}
MYSQL_DATABASE: ${DB:-commerce}
MYSQL_USER: ${DB_USER:-external_db_user}
MYSQL_PASSWORD: ${DB_PASS:-external_db_password}
volumes:
- ./external_db/mysql/:/docker-entrypoint-initdb.d/
- ./external_db/mysql/log:/var/log/mysql
command:
- --server-id=1
- --log-bin=mysql-bin
- --gtid_mode=ON
- --enforce_gtid_consistency
- --general_log=1
- --slow_query_log=1
healthcheck:
test: "/usr/bin/mysql --user=root --password=$${MYSQL_ROOT_PASSWORD} --execute \"SHOW DATABASES;\""
timeout: 10s
retries: 10
ports:
- "3306"
vtctld:
image: vitess/lite:v18.0.5-shopify-7
ports:
- "15000:$WEB_PORT"
- "$GRPC_PORT"
command: ["sh", "-c", " /vt/bin/vtctld \
$TOPOLOGY_FLAGS \
--cell $CELL \
--service_map 'grpc-vtctl,grpc-vtctld' \
--backup_storage_implementation file \
--file_backup_storage_root /vt/vtdataroot/backups \
--logtostderr=true \
--port $WEB_PORT \
--grpc_port $GRPC_PORT
"]
depends_on:
- consul1
- consul2
- consul3
depends_on:
external_db_host:
condition: service_healthy
vtgate:
image: vitess/lite:v18.0.5-shopify-7
ports:
- "15099:$WEB_PORT"
- "$GRPC_PORT"
- "15306:$MYSQL_PORT"
command: ["sh", "-c", "/vt/bin/vtgate \
$TOPOLOGY_FLAGS \
--logtostderr=true \
--port $WEB_PORT \
--grpc_port $GRPC_PORT \
--mysql_server_port $MYSQL_PORT \
--mysql_auth_server_impl none \
--cell $CELL \
--cells_to_watch $CELL \
--tablet_types_to_wait PRIMARY,REPLICA \
--service_map 'grpc-vtgateservice' \
--enable_system_settings=true \
"]
volumes:
- ".:/script"
environment:
- KEYSPACE
- DB
depends_on:
- vtctld
depends_on:
vttablet101:
condition: service_healthy
schemaload:
image: vitess/lite:v18.0.5-shopify-7
command:
- sh
- -c
- /script/schemaload.sh
environment:
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- TARGETTAB
- SLEEPTIME
- VSCHEMA_FILE
- SCHEMA_FILES
- POST_LOAD_FILE
- EXTERNAL_DB
volumes:
- .:/script
depends_on:
vttablet101:
condition: service_healthy
set_keyspace_durability_policy:
command:
- sh
- -c
- /script/set_keyspace_durability_policy.sh
depends_on:
- vttablet100
environment:
- KEYSPACES=$KEYSPACE
- GRPC_PORT=15999
image: vitess/lite:v18.0.5-shopify-7
volumes:
- .:/script
vttablet100:
image: vitess/lite:v18.0.5-shopify-7
ports:
- "15100:$WEB_PORT"
- "$GRPC_PORT"
- "3306"
volumes:
- ".:/script"
- "./backups:/vt/vtdataroot/backups"
environment:
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- DB
- EXTERNAL_DB
- DB_PORT
- DB_HOST
- DB_USER
- DB_PASS
- DB_CHARSET
- ROLE=primary
command: ["sh", "-c", "[ $$EXTERNAL_DB -eq 1 ] && /script/vttablet-up.sh 100 || exit 0"]
depends_on:
- vtctld
healthcheck:
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15
vttablet101:
image: vitess/lite:v18.0.5-shopify-7
ports:
- "15101:$WEB_PORT"
- "$GRPC_PORT"
- "3306"
volumes:
- ".:/script"
- "./backups:/vt/vtdataroot/backups"
environment:
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- DB
- EXTERNAL_DB
- DB_PORT
- DB_HOST
- DB_USER
- DB_PASS
- DB_CHARSET
- ROLE=primary
command: ["sh", "-c", "/script/vttablet-up.sh 101"]
depends_on:
- vtctld
healthcheck:
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15
vttablet102:
image: vitess/lite:v18.0.5-shopify-7
ports:
- "15102:$WEB_PORT"
- "$GRPC_PORT"
- "3306"
volumes:
- ".:/script"
- "./backups:/vt/vtdataroot/backups"
environment:
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- DB
- EXTERNAL_DB
- DB_PORT
- DB_HOST
- DB_USER
- DB_PASS
- DB_CHARSET
command: ["sh", "-c", "/script/vttablet-up.sh 102"]
depends_on:
- vtctld
- vttablet101
healthcheck:
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15
vttablet103:
image: vitess/lite:v18.0.5-shopify-7
ports:
- "15103:$WEB_PORT"
- "$GRPC_PORT"
- "3306"
volumes:
- ".:/script"
- "./backups:/vt/vtdataroot/backups"
environment:
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- DB
- EXTERNAL_DB
- DB_PORT
- DB_HOST
- DB_USER
- DB_PASS
- DB_CHARSET
command: ["sh", "-c", "/script/vttablet-up.sh 103"]
depends_on:
- vtctld
- vttablet101
healthcheck:
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15
vtorc:
image: vitess/lite:v18.0.5-shopify-7
command: ["sh", "-c", "/script/vtorc-up.sh"]
depends_on:
- vtctld
- set_keyspace_durability_policy
ports:
- "13000:8080"
volumes:
- ".:/script"
environment:
- WEB_PORT=8080
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- DB
- EXTERNAL_DB
- DB_PORT
- DB_HOST
- DB_USER
- DB_PASS
- DB_CHARSET
healthcheck:
test: ["CMD-SHELL","curl -s --fail --show-error localhost:8080/debug/health"]
interval: 5s
timeout: 10s
retries: 15
vreplication:
image: vitess/lite:v18.0.5-shopify-7
volumes:
- ".:/script"
environment:
- TOPOLOGY_FLAGS
- WEB_PORT
- GRPC_PORT
- CELL
- KEYSPACE
- DB
- EXTERNAL_DB
- DB_PORT
- DB_HOST
- DB_USER
- DB_PASS
- DB_CHARSET
command: ["sh", "-c", "[ $$EXTERNAL_DB -eq 1 ] && /script/externaldb_vreplication.sh || exit 0"]
depends_on:
- vtctld