-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose.yml
335 lines (332 loc) · 8.42 KB
/
docker-compose.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
329
330
331
332
333
334
335
version: '3.7'
# https://docs.docker.com/compose/compose-file/
# 只包含 public Demo 不包含 strategy 等信息
# 启动:docker-compose -f up -d
# 停止:docker-compose -f down
##############################
# 从 v3.7 开始(对于 3.x 系列),或者从 v2.4 开始(对于 2.x 系列),扩展字段也可以被放在 服务,卷,网络,配置项以及敏感信息项顶级章节之下的第一级
##############################
x-logging:
&default-logging
options:
max-size: '20m'
max-file: '10'
driver: json-file
x-deploy:
&default-deploy
replicas: 1
update_config:
delay: 1s
restart_policy: # 当容器实例退出时,如何重启。替换 restart
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
resources: # 配置资源约束
limits:
cpus: '0.50'
memory: 50M
reservations:
cpus: '0.25'
memory: 20M
x-labels:
&default-labels
mshk.top/instance: "microservice-exchange"
mshk.top/site: "mshk.top"
x-networks:
&default-networks
- mshk-top
services:
consul:
command: -server -bootstrap -ui-dir /ui
image: progrium/consul:latest
hostname: consul
ports:
- '8300:8300'
- '8301:8301'
- '8301:8301/udp'
- '8500:8500'
- '8600:8600'
- '8600:8600/udp'
depends_on:
- dbproxy
networks: *default-networks
##############################
# micro api
##############################
microapi:
command: --registry=consul --registry_address=consul:8500 api --handler=api
image: microhq/micro:latest
hostname: microapi
links:
- consul
depends_on:
- consul
ports:
- "8080:8080"
networks: *default-networks
deploy:
replicas: 1
update_config:
delay: 1s
restart_policy:
condition: on-failure
# ##############################
# # micro web
# ##############################
microweb:
command: --registry=consul --registry_address=consul:8500 web
image: microhq/micro:latest
hostname: microweb
links:
- consul
depends_on:
- consul
ports:
- "8082:8082"
networks: *default-networks
deploy:
replicas: 1
update_config:
delay: 1s
restart_policy:
condition: on-failure
##############################
# jaeger
##############################
jaeger:
image: jaegertracing/all-in-one:1.11
hostname: jaeger
links:
- consul
environment:
- COLLECTOR_ZIPKIN_HTTP_PORT=9411
ports:
- "5775:5775/udp"
- "6831:6831/udp"
- "6832:6832/udp"
- "5778:5778"
- "16686:16686"
- "14268:14268"
- "14250:14250"
- "9411:9411"
networks: *default-networks
##############################
# DBProxy 数据库代理
##############################
dbproxy:
build: ./api/dbproxy
hostname: dbproxy
env_file: ./docker-compose.dbproxy.env
ports:
- "30080:13306"
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# api columns
##############################
apicolumns:
build: ./api/columns
command: --registry=consul --registry_address=consul:8500
hostname: apicolumns
env_file:
- ./docker-compose.jaeger.env
depends_on:
- microapi
- microweb
- srvcolumns
- jaeger
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# srv columns
##############################
srvcolumns:
build: ./srv/columns
command: --registry=consul --registry_address=consul:8500
hostname: srvcolumns
env_file:
- ./docker-compose.jaeger.env
- ./docker-compose.srv.common.env
depends_on:
- dbproxy
- jaeger
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# api role
##############################
apirole:
build: ./api/role
command: --registry=consul --registry_address=consul:8500
hostname: apirole
env_file:
- ./docker-compose.jaeger.env
depends_on:
- microapi
- microweb
- srvrole
- jaeger
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# srv role
##############################
srvrole:
build: ./srv/role
command: --registry=consul --registry_address=consul:8500
hostname: srvrole
env_file:
- ./docker-compose.jaeger.env
- ./docker-compose.srv.common.env
depends_on:
- jaeger
- dbproxy
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# api users
##############################
apiusers:
build: ./api/users
command: --registry=consul --registry_address=consul:8500
hostname: apiusers
env_file:
- ./docker-compose.jaeger.env
depends_on:
- microapi
- jaeger
- microweb
- srvusers
- srvhistoryuserlogin
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# srv users
##############################
srvusers:
build: ./srv/users
command: --registry=consul --registry_address=consul:8500
hostname: srvusers
env_file:
- ./docker-compose.jaeger.env
- ./docker-compose.srv.common.env
depends_on:
- srvhistoryuserlogin
- jaeger
- dbproxy
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# srvhistoryuserlogin
##############################
srvhistoryuserlogin:
build: ./srv/historyuserlogin
command: --registry=consul --registry_address=consul:8500
hostname: srvhistoryuserlogin
env_file:
- ./docker-compose.jaeger.env
- ./docker-compose.srv.common.env
depends_on:
- jaeger
- dbproxy
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# api usersgroup
##############################
apiusersgroup:
build: ./api/usersgroup
command: --registry=consul --registry_address=consul:8500
hostname: apiusersgroup
env_file:
- ./docker-compose.jaeger.env
depends_on:
- microapi
- microweb
- srvusersgroup
- jaeger
- dbproxy
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# srv usersgroup
##############################
srvusersgroup:
build: ./srv/usersgroup
command: --registry=consul --registry_address=consul:8500
hostname: srvusersgroup
env_file:
- ./docker-compose.jaeger.env
- ./docker-compose.srv.common.env
depends_on:
- jaeger
- dbproxy
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# beego web
##############################
web:
build: ./web
ports:
- "18080:80"
environment:
- MICROSERVICE_HOSTPORT=http://microapi:8080
- HttpPort=80
depends_on:
- jaeger
- apiusers
- apicolumns
- apirole
- apiusersgroup
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
##############################
# swagger
##############################
swagger:
build: ./swagger
ports:
- "18081:8080"
networks: *default-networks
logging: *default-logging
labels: *default-labels
deploy: *default-deploy
#############################
# registrator 监听容器中暴露的端口,端口发生变化,通知注册中心作出相应处理
#############################
# registrator:
# image: gliderlabs/registrator:master
# hostname: registrator
# depends_on:
# - "consul"
# volumes:
# - "/var/run/docker.sock:/tmp/docker.sock"
# command: -internal consul://consul:8500
# 统一网络设置
# 在单节点宿主机上使用 bridge 驱动,而在 swarm mode 中使用 overlay 驱动。
networks:
mshk-top: