-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
120 lines (116 loc) · 4.2 KB
/
Copy pathdocker-compose.yml
File metadata and controls
120 lines (116 loc) · 4.2 KB
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
# MiniCPM-o 多 worker 单 gateway 部署(docker compose)
#
# 架构:
# gateway ×1 :8006 torch-free 控制面;/v1/realtime 入口 + 调度 + 录制
# worker-backend ×N 每个独占 1 张 GPU;容器内 backend(:22500)+ worker(:22400,纯转发)
#
# 拓扑要点:
# - 每个 worker-backend 显式绑定一张特定 GPU(device_ids),不能用 --scale(会抢同一张卡)。
# - 容器内 GPU 永远是 0(GPU_ID=0):reservation 决定它看到宿主机哪张卡,容器内就叫 cuda:0。
# - worker 启动后向 gateway 内部端口动态注册,gateway 不再持有静态 worker 列表。
# - worker-backend 挂模型(只读)、不挂 data(纯净);gateway 挂 data(录制持久化)、不要 GPU。
# - 模型权重不进镜像,运行时挂载;路径由 MODEL_HOST_PATH 指定。
#
# 增减 GPU = 增删 worker-backend-N service;worker 会自动注册到 gateway。
#
# 用法:
# MODEL_HOST_PATH=/root/xubokai/MiniCPM-o-4_5 docker compose up -d --build
# docker compose logs -f gateway
# docker compose logs -f worker-backend-0
x-worker-backend: &worker-backend-base
build:
context: .
dockerfile: docker/Dockerfile.worker-backend
image: minicpm-wb:dev
environment:
GPU_ID: "0" # 容器内恒为 0(见上)
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
restart: unless-stopped
healthcheck:
# 查 worker /health;转发模式下 backend 是否就绪由 entrypoint 门控保证
test: ["CMD", "curl", "-sf", "http://127.0.0.1:22400/health"]
interval: 15s
timeout: 5s
retries: 40 # 模型加载 ~90s,给足重试(40×15s=10min)
start_period: 120s
logging:
driver: json-file
options: {max-size: "50m", max-file: "3"}
services:
worker-backend-0:
<<: *worker-backend-base
container_name: minicpm-wb-0
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
WORKER_ID: "worker-backend-0"
WORKER_ENDPOINT: "worker-backend-0:22400"
WORKER_GPU_GROUP: "gpu-0"
volumes:
- ${MODEL_HOST_PATH:?set MODEL_HOST_PATH to the host model dir}:/models/MiniCPM-o-4_5:ro
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["0"]
capabilities: [gpu]
worker-backend-1:
<<: *worker-backend-base
container_name: minicpm-wb-1
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
WORKER_ID: "worker-backend-1"
WORKER_ENDPOINT: "worker-backend-1:22400"
WORKER_GPU_GROUP: "gpu-1"
volumes:
- ${MODEL_HOST_PATH:?set MODEL_HOST_PATH to the host model dir}:/models/MiniCPM-o-4_5:ro
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["1"]
capabilities: [gpu]
gateway:
build:
context: .
dockerfile: docker/Dockerfile.gateway
image: minicpm-gateway:dev
container_name: minicpm-gateway
# HTTPS:实时音视频页面(omni/audio_duplex)需要 https —— 浏览器仅在 https/localhost
# 下提供 navigator.mediaDevices(麦克风)。证书从宿主机挂载(不进镜像),默认读 certs/cert.pem。
# 纯文字 /turnbased 不需要麦克风,http 也能用;要降级 http 把下面 --https 段换成 ["--http"]。
command:
- "--host"
- "0.0.0.0"
- "--port"
- "8006"
- "--internal-port"
- "8007"
- "--https"
- "--ssl-certfile"
- "/app/certs/cert.pem"
- "--ssl-keyfile"
- "/app/certs/key.pem"
ports:
- "${GATEWAY_HOST_PORT:-8006}:8006"
expose:
- "8007"
volumes:
- ${DATA_HOST_PATH:-./data}:/app/data # session 录制持久化到 host
- ${CERTS_HOST_PATH:-./certs}:/app/certs:ro # TLS 证书从宿主机挂载(只读),不进镜像
restart: unless-stopped
logging:
driver: json-file
options: {max-size: "50m", max-file: "3"}