Skip to content

Commit 32a3b92

Browse files
authored
perf: deploy docs; docker-compose (#5722)
* docs: https://localhost => http://localhost * chore: docker compose; deploy/dev docs * chore: quick-start page * chore: add comment & remove leading space of vector config * chore: remove redundant install.sh scripts * chore: adjust milvus and ob, image dyanmic config; readme.md * chore: update pnpm-lock.yaml
1 parent 5a2ba5a commit 32a3b92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6155
-968
lines changed

deploy/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## 更新 docker compose 脚本
2+
3+
### 正常更新(不动服务,只改版本)
4+
1. 更新 `args.json` 中的版本号
5+
2.`FastGPT` 目录执行 `pnpm run gen:deploy` 即可
6+
7+
### 加服务
8+
比如要添加 `example` 服务:
9+
1. init.mjs 的 Services Enum 中添加 example
10+
2. 更新 templates/docker-compose.[dev|prod].yml 文件,把服务的相关配置加进去,并且:服务的 image 改为 ${{example.image}}:${{example.tag}}
11+
3.`args.json` 中添加 image 和 tag, 注意名字要和 `Service Enum` 中声明的一样才能被正确替换
12+
13+
### 加向量库
14+
比如添加 `exampleDB` 向量库:
15+
1. 添加 vector service 配置在 `templates/vector` 下面,例如 `templates/vector/exampleDB.txt` 内容可以参考其他 txt,注意缩进,image 名字也要替换成 ${{exampleDB.image}}:${{exampleDB:tag}}
16+
2.`args.json` 中添加 `exampleDB` 的配置
17+
3. init.mjs vector enum 中添加 `vector`
18+
4. init.mjs 中添加 vector 的相关配置:
19+
```ts
20+
const vector = {
21+
// pg, milvus, ob ...
22+
vector: {
23+
db: '', // 空即可
24+
config: `/
25+
VECTOR_URL:vectordb://xxxxx
26+
`, //注意 第一行反引号后面的 / 不能少(去除首个换行符); 左边的两个空格的缩进不能变,否则会语法错误
27+
extra: `` // 额外的配置,可以看 ob 的那个,需要一个 config 字段引入 init.sql
28+
}
29+
}
30+
```
31+
5. init.mjs 读入 vector 配置
32+
```json
33+
{ // 这是个块作用域, 直接搜 read in Vectors
34+
// read in Vectors
35+
// pg, ob ....
36+
const vectordb = fs.readFileSync(path.join(process.cwd(), 'templates', 'vector', 'vector.txt'));
37+
vector.vector.db = String(vectordb);
38+
}
39+
```
40+
6. init.mjs 最后生成的时候,需要添加
41+
```ts
42+
fs.promises.writeFile(
43+
path.join(process.cwd(), 'docker', 'cn', 'docker-compose.vector.yml'),
44+
replace(template, 'cn', VectorEnum.vector)
45+
),
46+
fs.promises.writeFile(
47+
path.join(process.cwd(), 'docker', 'global', 'docker-compose.ziliiz.yml'),
48+
replace(template, 'global', VectorEnum.vector)
49+
),
50+
```
51+
52+
## yaml 的锚点和引用
53+
54+
`&` 标志一个锚点
55+
56+
```yaml
57+
x-share-config: &x-share-config 'I am the config content'
58+
x-share-config-list: &x-share-config-list
59+
key1: value
60+
key2: value
61+
```
62+
63+
`*` 引用一个锚点
64+
```yaml
65+
some_other_example: *x-share-config-list
66+
```

deploy/args.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"tags": {
3+
"fastgpt": "v4.13.0",
4+
"fastgpt-sandbox": "v4.13.0",
5+
"fastgpt-mcp_server": "v4.13.0",
6+
"fastgpt-plugin": "v0.2.0",
7+
"aiproxy": "v0.3.2",
8+
"aiproxy-pg": "0.8.0-pg15",
9+
"mongo": "5.0.18",
10+
"redis": "7.2-alpine",
11+
"minio": "RELEASE.2025-09-07T16-13-09Z",
12+
"pg": "0.8.0-pg15",
13+
"milvus-minio": "RELEASE.2023-03-20T20-16-18Z",
14+
"milvus-etcd": "v3.5.5",
15+
"milvus-standalone": "v2.4.3",
16+
"oceanbase": "4.3.5-lts"
17+
},
18+
"images": {
19+
"cn": {
20+
"fastgpt": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt",
21+
"fastgpt-plugin": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin",
22+
"fastgpt-sandbox": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox",
23+
"fastgpt-mcp_server": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server",
24+
"aiproxy": "registry.cn-hangzhou.aliyuncs.com/labring/aiproxy",
25+
"aiproxy-pg": "registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector",
26+
"mongo": "registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo",
27+
"redis": "redis",
28+
"minio": "minio/minio",
29+
"pg": "registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector",
30+
"milvus-minio": "minio/minio",
31+
"milvus-etcd": "quay.io/coreos/etcd",
32+
"milvus-standalone": "milvusdb/milvus",
33+
"oceanbase": "oceanbase/oceanbase-ce"
34+
},
35+
"global": {
36+
"fastgpt": "ghcr.io/labring/fastgpt",
37+
"fastgpt-plugin": "ghcr.io/labring/fastgpt-plugin",
38+
"fastgpt-sandbox": "ghcr.io/labring/fastgpt-sandbox",
39+
"fastgpt-mcp_server": "ghcr.io/labring/fastgpt-mcp_server",
40+
"aiproxy": "ghcr.io/labring/aiproxy",
41+
"aiproxy-pg": "pgvector/pgvector",
42+
"mongo": "mongo",
43+
"redis": "redis",
44+
"minio": "minio/minio",
45+
"pg": "pgvector/pgvector",
46+
"milvus-minio": "minio/minio",
47+
"milvus-etcd": "quay.io/coreos/etcd",
48+
"milvus-standalone": "milvusdb/milvus",
49+
"oceanbase": "oceanbase/oceanbase-ce"
50+
}
51+
}
52+
}

deploy/dev/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!.gitignore
3+
!docker-compose.yml
4+
!docker-compose.cn.yml

deploy/dev/docker-compose.cn.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# 用于开发的 docker-compose 文件:
2+
# - 只包含 FastGPT 的最小化运行条件
3+
# - 没有 FastGPT 本体
4+
# - 所有端口都映射到外层
5+
# - pg: 5432
6+
# - mongo: 27017
7+
# - redis: 6379
8+
# - fastgpt-sandbox: 3002
9+
# - fastgpt-plugin: 3003
10+
# - aiproxy: 3010
11+
# - 使用 pgvector 作为默认的向量库
12+
13+
services:
14+
# Vector DB
15+
pg:
16+
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15
17+
container_name: pg
18+
restart: always
19+
ports: # 生产环境建议不要暴露
20+
- 5432:5432
21+
networks:
22+
- fastgpt
23+
environment:
24+
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
25+
- POSTGRES_USER=username
26+
- POSTGRES_PASSWORD=password
27+
- POSTGRES_DB=postgres
28+
volumes:
29+
- ./pg/data:/var/lib/postgresql/data
30+
healthcheck:
31+
test: ['CMD', 'pg_isready', '-U', 'username', '-d', 'postgres']
32+
interval: 5s
33+
timeout: 5s
34+
retries: 10
35+
36+
# DB
37+
mongo:
38+
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # cpu 不支持 AVX 时候使用 4.4.29
39+
container_name: mongo
40+
restart: always
41+
ports:
42+
- 27017:27017
43+
networks:
44+
- fastgpt
45+
command: mongod --keyFile /data/mongodb.key --replSet rs0
46+
environment:
47+
- MONGO_INITDB_ROOT_USERNAME=myusername
48+
- MONGO_INITDB_ROOT_PASSWORD=mypassword
49+
volumes:
50+
- ./mongo/data:/data/db
51+
entrypoint:
52+
- bash
53+
- -c
54+
- |
55+
openssl rand -base64 128 > /data/mongodb.key
56+
chmod 400 /data/mongodb.key
57+
chown 999:999 /data/mongodb.key
58+
echo 'const isInited = rs.status().ok === 1
59+
if(!isInited){
60+
rs.initiate({
61+
_id: "rs0",
62+
members: [
63+
{ _id: 0, host: "mongo:27017" }
64+
]
65+
})
66+
}' > /data/initReplicaSet.js
67+
# 启动MongoDB服务
68+
exec docker-entrypoint.sh "$$@" &
69+
70+
# 等待MongoDB服务启动
71+
until mongo -u myusername -p mypassword --authenticationDatabase admin --eval "print('waited for connection')"; do
72+
echo "Waiting for MongoDB to start..."
73+
sleep 2
74+
done
75+
76+
# 执行初始化副本集的脚本
77+
mongo -u myusername -p mypassword --authenticationDatabase admin /data/initReplicaSet.js
78+
79+
# 等待docker-entrypoint.sh脚本执行的MongoDB服务进程
80+
wait $$!
81+
redis:
82+
image: redis:7.2-alpine
83+
container_name: redis
84+
ports:
85+
- 6379:6379
86+
networks:
87+
- fastgpt
88+
restart: always
89+
command: |
90+
redis-server --requirepass mypassword --loglevel warning --maxclients 10000 --appendonly yes --save 60 10 --maxmemory 4gb --maxmemory-policy noeviction
91+
healthcheck:
92+
test: ['CMD', 'redis-cli', '-a', 'mypassword', 'ping']
93+
interval: 10s
94+
timeout: 3s
95+
retries: 3
96+
start_period: 30s
97+
volumes:
98+
- ./redis/data:/data
99+
fastgpt-minio:
100+
image: minio/minio:RELEASE.2025-09-07T16-13-09Z
101+
container_name: fastgpt-minio
102+
restart: always
103+
networks:
104+
- fastgpt
105+
ports:
106+
- '9000:9000'
107+
- '9001:9001'
108+
environment:
109+
- MINIO_ROOT_USER=minioadmin
110+
- MINIO_ROOT_PASSWORD=minioadmin
111+
volumes:
112+
- ./fastgpt-minio:/data
113+
command: server /data --console-address ":9001"
114+
healthcheck:
115+
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
116+
interval: 30s
117+
timeout: 20s
118+
retries: 3
119+
sandbox:
120+
container_name: sandbox
121+
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.13.0
122+
ports:
123+
- 3002:3000
124+
networks:
125+
- fastgpt
126+
restart: always
127+
fastgpt-mcp-server:
128+
container_name: fastgpt-mcp-server
129+
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server:v4.13.0
130+
ports:
131+
- 3005:3000
132+
networks:
133+
- fastgpt
134+
restart: always
135+
environment:
136+
- FASTGPT_ENDPOINT=http://fastgpt:3000
137+
fastgpt-plugin:
138+
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin:v0.2.0
139+
container_name: fastgpt-plugin
140+
restart: always
141+
ports:
142+
- 3003:3000
143+
networks:
144+
- fastgpt
145+
environment:
146+
- AUTH_TOKEN=token
147+
- S3_ENDPOINT=fastgpt-minio
148+
- S3_PORT=9000
149+
- S3_USE_SSL=false
150+
- S3_ACCESS_KEY=minioadmin
151+
- S3_SECRET_KEY=minioadmin
152+
- S3_BUCKET=fastgpt-plugins
153+
- S3_TOOL_BUCKET=fastgpt-tool # 系统工具,创建的临时文件,存储的桶,要求公开读私有写。
154+
- S3_PLUGIN_BUCKET=fastgpt-plugin # 系统插件热安装文件的桶,私有读写。
155+
- RETENTION_DAYS=15 # 系统工具临时文件保存天数
156+
- MONGODB_URI=mongodb://myusername:mypassword@mongo:27017/fastgpt?authSource=admin&directConnection=true
157+
- REDIS_URL=redis://default:mypassword@redis:6379
158+
depends_on:
159+
fastgpt-minio:
160+
condition: service_healthy
161+
# AI Proxy
162+
aiproxy:
163+
image: registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:v0.3.2
164+
container_name: aiproxy
165+
restart: unless-stopped
166+
ports:
167+
- 3010:3000
168+
depends_on:
169+
aiproxy_pg:
170+
condition: service_healthy
171+
networks:
172+
- fastgpt
173+
- aiproxy
174+
environment:
175+
# 对应 fastgpt 里的AIPROXY_API_TOKEN
176+
- ADMIN_KEY=aiproxy
177+
# 错误日志详情保存时间(小时)
178+
- LOG_DETAIL_STORAGE_HOURS=1
179+
# 数据库连接地址
180+
- SQL_DSN=postgres://postgres:aiproxy@aiproxy_pg:5432/aiproxy
181+
# 最大重试次数
182+
- RETRY_TIMES=3
183+
# 不需要计费
184+
- BILLING_ENABLED=false
185+
# 不需要严格检测模型
186+
- DISABLE_MODEL_CONFIG=true
187+
healthcheck:
188+
test: ['CMD', 'curl', '-f', 'http://localhost:3000/api/status']
189+
interval: 5s
190+
timeout: 5s
191+
retries: 10
192+
aiproxy_pg:
193+
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15 # docker hub
194+
restart: unless-stopped
195+
container_name: aiproxy_pg
196+
volumes:
197+
- ./aiproxy_pg:/var/lib/postgresql/data
198+
networks:
199+
- aiproxy
200+
environment:
201+
TZ: Asia/Shanghai
202+
POSTGRES_USER: postgres
203+
POSTGRES_DB: aiproxy
204+
POSTGRES_PASSWORD: aiproxy
205+
healthcheck:
206+
test: ['CMD', 'pg_isready', '-U', 'postgres', '-d', 'aiproxy']
207+
interval: 5s
208+
timeout: 5s
209+
retries: 10
210+
networks:
211+
fastgpt:
212+
aiproxy:

0 commit comments

Comments
 (0)