Skip to content

Commit 51886b1

Browse files
committed
build(docker): 添加跨进程服务发现环境变量配置
为所有服务实例添加 services__ 发现环境变量, 使 Game 和 Social 进程能够互相发现并通信。
1 parent 13d4fed commit 51886b1

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

docker-compose.multi.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
name: gfx-multi
22

3+
x-launcher-discovery-env: &launcher-discovery-env
4+
services__Social_2001__tcp__0: "tcp://social-1:29400"
5+
services__Social_2002__tcp__0: "tcp://social-2:29401"
6+
services__Social__tcp__0: "tcp://social-1:29400"
7+
services__Game_1001__tcp__0: "tcp://game-1:29100"
8+
services__Game_1002__tcp__0: "tcp://game-2:29101"
9+
services__Game_1003__tcp__0: "tcp://game-3:29102"
10+
services__Game_1004__tcp__0: "tcp://game-4:29103"
11+
services__Game_1005__tcp__0: "tcp://game-5:29104"
12+
services__Game_1006__tcp__0: "tcp://game-6:29105"
13+
services__Game_1007__tcp__0: "tcp://game-7:29106"
14+
services__Game_1008__tcp__0: "tcp://game-8:29107"
15+
services__Game_1009__tcp__0: "tcp://game-9:29108"
16+
services__Game_1010__tcp__0: "tcp://game-10:29109"
17+
services__Game__tcp__0: "tcp://game-1:29100"
18+
319
services:
420
mongo:
521
image: mongo:8.2
@@ -35,6 +51,8 @@ services:
3551
- "--IsEnableHttp=true"
3652
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
3753
- "--DataBaseName=gameframex_multi"
54+
environment:
55+
<<: *launcher-discovery-env
3856
ports:
3957
- "49400:29400"
4058
- "48081:28081"
@@ -61,6 +79,8 @@ services:
6179
- "--IsEnableHttp=true"
6280
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
6381
- "--DataBaseName=gameframex_multi"
82+
environment:
83+
<<: *launcher-discovery-env
6484
ports:
6585
- "49401:29401"
6686
- "48083:28083"
@@ -91,6 +111,8 @@ services:
91111
- "--IsEnableHttp=true"
92112
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
93113
- "--DataBaseName=gameframex_multi"
114+
environment:
115+
<<: *launcher-discovery-env
94116
ports:
95117
- "49100:29100"
96118
- "48080:28080"
@@ -121,6 +143,8 @@ services:
121143
- "--IsEnableHttp=true"
122144
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
123145
- "--DataBaseName=gameframex_multi"
146+
environment:
147+
<<: *launcher-discovery-env
124148
ports:
125149
- "49101:29101"
126150
- "48082:28082"
@@ -151,6 +175,8 @@ services:
151175
- "--IsEnableHttp=true"
152176
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
153177
- "--DataBaseName=gameframex_multi"
178+
environment:
179+
<<: *launcher-discovery-env
154180
ports:
155181
- "49102:29102"
156182
- "48084:28084"
@@ -181,6 +207,8 @@ services:
181207
- "--IsEnableHttp=true"
182208
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
183209
- "--DataBaseName=gameframex_multi"
210+
environment:
211+
<<: *launcher-discovery-env
184212
ports:
185213
- "49103:29103"
186214
- "48086:28086"
@@ -211,6 +239,8 @@ services:
211239
- "--IsEnableHttp=true"
212240
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
213241
- "--DataBaseName=gameframex_multi"
242+
environment:
243+
<<: *launcher-discovery-env
214244
ports:
215245
- "49104:29104"
216246
- "48088:28088"
@@ -241,6 +271,8 @@ services:
241271
- "--IsEnableHttp=true"
242272
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
243273
- "--DataBaseName=gameframex_multi"
274+
environment:
275+
<<: *launcher-discovery-env
244276
ports:
245277
- "49105:29105"
246278
- "48090:28090"
@@ -271,6 +303,8 @@ services:
271303
- "--IsEnableHttp=true"
272304
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
273305
- "--DataBaseName=gameframex_multi"
306+
environment:
307+
<<: *launcher-discovery-env
274308
ports:
275309
- "49106:29106"
276310
- "48092:28092"
@@ -301,6 +335,8 @@ services:
301335
- "--IsEnableHttp=true"
302336
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
303337
- "--DataBaseName=gameframex_multi"
338+
environment:
339+
<<: *launcher-discovery-env
304340
ports:
305341
- "49107:29107"
306342
- "48094:28094"
@@ -331,6 +367,8 @@ services:
331367
- "--IsEnableHttp=true"
332368
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
333369
- "--DataBaseName=gameframex_multi"
370+
environment:
371+
<<: *launcher-discovery-env
334372
ports:
335373
- "49108:29108"
336374
- "48096:28096"
@@ -361,6 +399,8 @@ services:
361399
- "--IsEnableHttp=true"
362400
- "--DataBaseUrl=mongodb://mongo:27017/?authSource=admin"
363401
- "--DataBaseName=gameframex_multi"
402+
environment:
403+
<<: *launcher-discovery-env
364404
ports:
365405
- "49109:29109"
366406
- "48098:28098"

0 commit comments

Comments
 (0)