跳到主要内容

Docker部署

镜像说明

MCP Gateway 提供两种部署方式:

  1. All-in-One 部署:所有服务打包在一个容器中,适合单机部署或本机使用
  2. 多容器部署:各个服务独立部署,适合生产环境或集群部署

镜像仓库

镜像发布到以下三个仓库:

  • Docker Hub: docker.io/ifuryst/mcp-gateway-*
  • GitHub Container Registry: ghcr.io/mcp-ecosystem/mcp-gateway/*
  • 阿里云容器镜像服务: registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-*

ghcr支持多层目录,所以组织形式会更清晰,Docker和阿里云的仓库只能一层目录,因此后面镜像名用-拼接

镜像标签

  • latest: 最新版本
  • vX.Y.Z: 特定版本号

注意: 目前 MCP Gateway 正在快速迭代中!因此建议通过版本号部署会更可靠一点

可用镜像

# All-in-One 版本
docker pull docker.io/ifuryst/mcp-gateway-allinone:latest
docker pull ghcr.io/mcp-ecosystem/mcp-gateway/allinone:latest
docker pull registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-allinone:latest

# API Server
docker pull docker.io/ifuryst/mcp-gateway-apiserver:latest
docker pull ghcr.io/mcp-ecosystem/mcp-gateway/apiserver:latest
docker pull registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-apiserver:latest

# MCP Gateway
docker pull docker.io/ifuryst/mcp-gateway-mcp-gateway:latest
docker pull ghcr.io/mcp-ecosystem/mcp-gateway/mcp-gateway:latest
docker pull registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-mcp-gateway:latest

# Mock User Service
docker pull docker.io/ifuryst/mcp-gateway-mock-user-svc:latest
docker pull ghcr.io/mcp-ecosystem/mcp-gateway/mock-user-svc:latest
docker pull registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-mock-user-svc:latest

# Web 前端
docker pull docker.io/ifuryst/mcp-gateway-web:latest
docker pull ghcr.io/mcp-ecosystem/mcp-gateway/web:latest
docker pull registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-web:latest

部署

All-in-One 部署

All-in-One 部署将所有服务打包在一个容器中,适合单机部署或本机使用。包含以下服务:

  • API Server: 管理平台后端,可理解为控制面
  • MCP Gateway: 核心服务,负责实际的网关服务,可理解为数据面
  • Mock User Service: 模拟用户服务,提供测试用的用户服务(你的存量API服务可能就是类似这样的)
  • Web 前端: 管理平台前端,提供可视化的管理界面
  • Nginx: 反向代理其他几个服务

使用 Supervisor 管理服务进程。日志会全部图吐到 stdout 里

端口说明

  • 8080: Web 界面端口
  • 5234: API Server 端口
  • 5235: MCP Gateway 端口
  • 5335: MCP Gateway 管理端口(承载诸如reload的内部接口,生产环境切勿对外)
  • 5236: Mock User Service 端口

数据持久化

建议挂载以下目录:

  • /app/configs: 配置文件目录
  • /app/data: 数据目录
  • /app/.env: 环境变量文件

示例命令

  1. 创建必要的目录并下载配置文件:
mkdir -p mcp-gateway/{configs,data}
cd mcp-gateway/
curl -sL https://raw.githubusercontent.com/mcp-ecosystem/mcp-gateway/refs/heads/main/configs/apiserver.yaml -o configs/apiserver.yaml
curl -sL https://raw.githubusercontent.com/mcp-ecosystem/mcp-gateway/refs/heads/main/configs/mcp-gateway.yaml -o configs/mcp-gateway.yaml
curl -sL https://raw.githubusercontent.com/mcp-ecosystem/mcp-gateway/refs/heads/main/.env.example -o .env.allinone

LLMs可以按需更换,如换成千问(需要兼容OpenAI)

OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1/
OPENAI_API_KEY=sk-yourkeyhere
OPENAI_MODEL=qwen-turbo
  1. 使用 Docker 运行 MCP Gateway:
# 使用阿里云容器镜像服务镜像(建议在中国境内的服务器或设备使用)
docker run -d \
--name mcp-gateway \
-p 8080:80 \
-p 5234:5234 \
-p 5235:5235 \
-p 5335:5335 \
-p 5236:5236 \
-e ENV=production \
-v $(pwd)/configs:/app/configs \
-v $(pwd)/data:/app/data \
-v $(pwd)/.env.allinone:/app/.env \
--restart unless-stopped \
registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-allinone:latest

# 使用 GitHub Container Registry 镜像
docker run -d \
--name mcp-gateway \
-p 8080:80 \
-p 5234:5234 \
-p 5235:5235 \
-p 5335:5335 \
-p 5236:5236 \
-e ENV=production \
-v $(pwd)/configs:/app/configs \
-v $(pwd)/data:/app/data \
-v $(pwd)/.env.allinone:/app/.env \
--restart unless-stopped \
ghcr.io/mcp-ecosystem/mcp-gateway/allinone:latest

注意事项

  1. 确保配置文件和环境变量文件正确配置
  2. 建议使用版本号标签而不是 latest
  3. 生产环境建议配置适当的资源限制
  4. 确保挂载的目录有正确的权限