Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit cfa1fbd

Browse files
committed
docs: Add multi docker deployment
1 parent fe9bb5a commit cfa1fbd

File tree

8 files changed

+587
-202
lines changed
  • docs/deployment
  • i18n
    • de/docusaurus-plugin-content-docs/current/deployment
    • en/docusaurus-plugin-content-docs/current/deployment
    • es/docusaurus-plugin-content-docs/current/deployment
    • fr/docusaurus-plugin-content-docs/current/deployment
    • hi/docusaurus-plugin-content-docs/current/deployment
    • ja/docusaurus-plugin-content-docs/current/deployment
    • ko/docusaurus-plugin-content-docs/current/deployment

8 files changed

+587
-202
lines changed

docs/deployment/docker.md

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,279 @@ docker run -d \
140140
3. 生产环境建议配置适当的资源限制
141141
4. 确保挂载的目录有正确的权限
142142

143+
### 多容器部署
144+
多个服务独立部署,适合生产环境或集群部署。包含以下服务:
145+
- **mcp-gateway**: 核心服务,负责实际的网关服务,可理解为数据面
146+
- **web(包含apiserver)**: 管理平台及后端,可理解为控制面
147+
- **mock-server**: 模拟服务,提供测试用的服务
148+
149+
适合在生产环境使用,可以按需部署,尤其针对`mcp-gateway`可以多副本部署,实现高可用
150+
151+
以下展示使用Docker Compose 部署的示例,该示例:
152+
1. 使用的是postgres作为数据库存储session、代理配置等信息
153+
2. 采用multi即每个服务单独容器部署
154+
3. 使用redis用于配置更新通知、OAuth存储等用途
155+
156+
大体步骤:
157+
1. 配置[docker-compose.yaml](https://raw.githubusercontent.com/mcp-ecosystem/mcp-gateway/refs/heads/main/deploy/docker/multi/docker-compose.yml)
158+
2.[.env.example](https://raw.githubusercontent.com/mcp-ecosystem/mcp-gateway/refs/heads/main/.env.example)拷贝并配置.env
159+
3. 运行`docker compose up -d`
160+
4. 按需配置`Nginx`等LB层
161+
162+
#### docker-compose.yaml
163+
注意事项
164+
1. 修改里面的db, redis相关的账号密码
165+
2. 按需修改暴露的端口,需要留意目前配置方式可能会让相应端口暴露到公网
166+
167+
```yaml
168+
services:
169+
postgres:
170+
image: postgres:16
171+
environment:
172+
POSTGRES_USER: postgres
173+
POSTGRES_PASSWORD: "**********"
174+
POSTGRES_DB: mcp-gateway
175+
volumes:
176+
- ./db:/var/lib/postgresql/data
177+
- /etc/localtime:/etc/localtime:ro
178+
- /etc/timezone:/etc/timezone:ro
179+
restart: always
180+
181+
redis:
182+
image: redis:7
183+
ports:
184+
- "6379:6379"
185+
volumes:
186+
- ./redis:/data
187+
- /etc/localtime:/etc/localtime:ro
188+
- /etc/timezone:/etc/timezone:ro
189+
command: redis-server --appendonly yes --save "900 1" --save "300 10" --save "60 10000" --requirepass "**********"
190+
restart: always
191+
192+
web:
193+
image: ghcr.io/mcp-ecosystem/mcp-gateway/web:latest
194+
ports:
195+
- "8080:80"
196+
- "5234:5234"
197+
environment:
198+
- ENV=production
199+
- TZ=Asia/Shanghai
200+
volumes:
201+
- ./.env:/app/.env
202+
- ./data:/app/data
203+
depends_on:
204+
- postgres
205+
- mcp-gateway
206+
- mock-server
207+
restart: always
208+
209+
mcp-gateway:
210+
image: ghcr.io/mcp-ecosystem/mcp-gateway/mcp-gateway:latest
211+
ports:
212+
- "5235:5235"
213+
environment:
214+
- ENV=production
215+
- TZ=Asia/Shanghai
216+
volumes:
217+
- ./.env:/app/.env
218+
- ./data:/app/data
219+
depends_on:
220+
- postgres
221+
restart: always
222+
223+
mock-server:
224+
image: ghcr.io/mcp-ecosystem/mcp-gateway/mock-server:latest
225+
ports:
226+
- "5236:5236"
227+
environment:
228+
- ENV=production
229+
- TZ=Asia/Shanghai
230+
volumes:
231+
- ./.env:/app/.env
232+
depends_on:
233+
- postgres
234+
restart: always
235+
```
236+
237+
#### .env
238+
以下只是示例配置,一定要根据你的环节和需求去调整配置!
239+
1. 修改相关db, redis相关的账号密码
240+
241+
```bash
242+
# Logger configuration for apiserver
243+
APISERVER_LOGGER_LEVEL=info
244+
APISERVER_LOGGER_FORMAT=json
245+
APISERVER_LOGGER_OUTPUT=stdout
246+
APISERVER_LOGGER_FILE_PATH=/var/log/mcp-gateway/apiserver.log
247+
APISERVER_LOGGER_MAX_SIZE=100
248+
APISERVER_LOGGER_MAX_BACKUPS=3
249+
APISERVER_LOGGER_MAX_AGE=7
250+
APISERVER_LOGGER_COMPRESS=true
251+
APISERVER_LOGGER_COLOR=false
252+
APISERVER_LOGGER_STACKTRACE=true
253+
254+
# Logger configuration for mcp-gateway
255+
LOGGER_LEVEL=info
256+
LOGGER_FORMAT=json
257+
LOGGER_OUTPUT=stdout
258+
LOGGER_FILE_PATH=/var/log/mcp-gateway/mcp-gateway.log
259+
LOGGER_MAX_SIZE=100
260+
LOGGER_MAX_BACKUPS=3
261+
LOGGER_MAX_AGE=7
262+
LOGGER_COMPRESS=true
263+
LOGGER_COLOR=false
264+
LOGGER_STACKTRACE=true
265+
266+
# Database Configuration
267+
APISERVER_DB_TYPE=postgres
268+
APISERVER_DB_HOST=postgres
269+
APISERVER_DB_PORT=5432
270+
APISERVER_DB_USER=unla
271+
APISERVER_DB_PASSWORD=**********
272+
APISERVER_DB_NAME=unla
273+
APISERVER_DB_SSL_MODE=disable
274+
275+
# Gateway Configurations Storage Configuration
276+
GATEWAY_STORAGE_TYPE=db
277+
GATEWAY_DB_TYPE=postgres
278+
GATEWAY_DB_HOST=postgres
279+
GATEWAY_DB_PORT=5432
280+
GATEWAY_DB_USER=unla
281+
GATEWAY_DB_PASSWORD=**********
282+
GATEWAY_DB_NAME=unla
283+
GATEWAY_DB_SSL_MODE=disable
284+
GATEWAY_STORAGE_DISK_PATH=
285+
GATEWAY_STORAGE_API_URL=
286+
GATEWAY_STORAGE_API_CONFIG_JSON_PATH=
287+
GATEWAY_STORAGE_API_TIMEOUT=5s
288+
GATEWAY_STORAGE_REVISION_HISTORY_LIMIT=10
289+
290+
# Notifier Configuration
291+
APISERVER_NOTIFIER_ROLE=sender
292+
APISERVER_NOTIFIER_TYPE=redis
293+
## Signal Notifier Settings
294+
APISERVER_NOTIFIER_SIGNAL=SIGHUP
295+
APISERVER_NOTIFIER_SIGNAL_PID=/var/run/mcp-gateway.pid
296+
## API Notifier Settings
297+
APISERVER_NOTIFIER_API_PORT=5335
298+
APISERVER_NOTIFIER_API_TARGET_URL=http://mcp-gateway:5335/_reload
299+
## Redis Notifier Settings
300+
APISERVER_NOTIFIER_REDIS_ADDR=redis:6379
301+
APISERVER_NOTIFIER_REDIS_PASSWORD=**********
302+
APISERVER_NOTIFIER_REDIS_DB=0
303+
APISERVER_NOTIFIER_REDIS_TOPIC=mcp-gateway:reload
304+
305+
# Notifier Configuration
306+
NOTIFIER_ROLE=receiver
307+
NOTIFIER_TYPE=redis
308+
## Signal Notifier Settings
309+
NOTIFIER_SIGNAL=SIGHUP
310+
NOTIFIER_SIGNAL_PID=/var/run/mcp-gateway.pid
311+
## API Notifier Settings
312+
NOTIFIER_API_PORT=5335
313+
NOTIFIER_API_TARGET_URL=http://mcp-gateway:5335/_reload
314+
## Redis Notifier Settings
315+
NOTIFIER_REDIS_ADDR=redis:6379
316+
NOTIFIER_REDIS_USERNAME=
317+
NOTIFIER_REDIS_PASSWORD=**********
318+
NOTIFIER_REDIS_DB=0
319+
NOTIFIER_REDIS_TOPIC=mcp-gateway:reload
320+
321+
# Session storage type: memory or redis
322+
SESSION_STORAGE_TYPE=redis
323+
SESSION_REDIS_ADDR=redis:6379
324+
SESSION_REDIS_USERNAME=
325+
SESSION_REDIS_PASSWORD=**********
326+
SESSION_REDIS_DB=0
327+
SESSION_REDIS_TOPIC=mcp-gateway:session
328+
SESSION_REDIS_PREFIX=
329+
SESSION_REDIS_TTL=24h
330+
331+
OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1/
332+
OPENAI_API_KEY=sk-**********
333+
OPENAI_MODEL=qwen-turbo-2025-04-28
334+
335+
MCP_GATEWAY_PID=/var/run/mcp-gateway.pid
336+
MCP_GATEWAY_PORT=5235
337+
MCP_GATEWAY_RELOAD_INTERVAL=600s
338+
MCP_GATEWAY_RELOAD_SWITCH=true
339+
340+
VITE_API_BASE_URL=/api
341+
VITE_WS_BASE_URL=/ws
342+
VITE_MCP_GATEWAY_BASE_URL=/mcp
343+
VITE_BASE_URL=/
344+
345+
APISERVER_JWT_SECRET_KEY=**********
346+
APISERVER_JWT_DURATION=72h
347+
348+
TZ=Asia/Shanghai
349+
350+
SUPER_ADMIN_USERNAME=admin
351+
SUPER_ADMIN_PASSWORD=**********
352+
353+
APISERVER_I18N_PATH=./configs/i18n
354+
355+
OAUTH2_ISSUER=https://github.com/mcp-ecosystem/mcp-gateway
356+
OAUTH2_STORAGE_TYPE=redis
357+
OAUTH2_REDIS_ADDR=redis:6379
358+
OAUTH2_REDIS_PASSWORD=**********
359+
OAUTH2_REDIS_DB=1
360+
```
143361

362+
#### nginx
363+
这边只提供vhosts的配置方式举例:
364+
1. 按需调整你的域名
365+
2. 按需调整服务到反代到上游服务器的地址
366+
367+
```nginx
368+
server {
369+
server_name example.docs.unla.amoylab.com;
370+
371+
location / {
372+
proxy_pass http://127.0.0.1:8080;
373+
proxy_set_header Host $host;
374+
}
375+
376+
location /api/ {
377+
proxy_pass http://127.0.0.1:5234/api/;
378+
proxy_set_header Host $host;
379+
proxy_set_header X-Real-IP $remote_addr;
380+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
381+
proxy_set_header X-Forwarded-Proto $scheme;
382+
}
383+
384+
location /ws/ {
385+
proxy_pass http://127.0.0.1:5234/api/ws/;
386+
proxy_http_version 1.1;
387+
proxy_set_header Upgrade $http_upgrade;
388+
proxy_set_header Connection "upgrade";
389+
proxy_set_header Host $host;
390+
proxy_set_header X-Real-IP $remote_addr;
391+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
392+
proxy_set_header X-Forwarded-Proto $scheme;
393+
}
394+
395+
location /gateway/ {
396+
proxy_pass http://127.0.0.1:5235/;
397+
proxy_set_header Host $host;
398+
proxy_set_header X-Real-IP $remote_addr;
399+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
400+
proxy_set_header X-Forwarded-Proto $scheme;
401+
402+
proxy_buffering off;
403+
proxy_cache off;
404+
chunked_transfer_encoding off;
405+
proxy_read_timeout 3600s;
406+
proxy_send_timeout 3600s;
407+
}
408+
409+
location /mock/ {
410+
proxy_pass http://127.0.0.1:5236/;
411+
proxy_set_header Host $host;
412+
}
413+
}
414+
```
144415

416+
#### 重要访问URL
417+
1. Web: [https://example.docs.unla.amoylab.com/](https://example.docs.unla.amoylab.com/)
418+
2. MCP Gateway: [https://example.docs.unla.amoylab.com/gateway/*](https://example.docs.unla.amoylab.com/gateway/*),比如[https://example.docs.unla.amoylab.com/gateway/mcp/user/mcp](https://example.docs.unla.amoylab.com/gateway/mcp/user/mcp)

0 commit comments

Comments
 (0)