Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions deploy/README.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 怎么维护镜像名和版本
  2. 怎么改环境变量配置
  3. 怎么添加新服务
  4. 怎么添加向量库

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## 更新 docker compose 脚本

### 正常更新(不动服务,只改版本)
1. 更新 `args.json` 中的版本号
2. 在 `FastGPT` 目录执行 `pnpm run gen:deploy` 即可

### 加服务
比如要添加 `example` 服务:
1. init.mjs 的 Services Enum 中添加 example
2. 更新 templates/docker-compose.[dev|prod].yml 文件,把服务的相关配置加进去,并且:服务的 image 改为 ${{example.image}}:${{example.tag}}
3. 在 `args.json` 中添加 image 和 tag, 注意名字要和 `Service Enum` 中声明的一样才能被正确替换

### 加向量库
比如添加 `exampleDB` 向量库:
1. 添加 vector service 配置在 `templates/vector` 下面,例如 `templates/vector/exampleDB.txt` 内容可以参考其他 txt,注意缩进,image 名字也要替换成 ${{exampleDB.image}}:${{exampleDB:tag}}
2. 在 `args.json` 中添加 `exampleDB` 的配置
3. init.mjs vector enum 中添加 `vector`
4. init.mjs 中添加 vector 的相关配置:
```ts
const vector = {
// pg, milvus, ob ...
vector: {
db: '', // 空即可
config: `/
VECTOR_URL:vectordb://xxxxx
`, //注意 第一行反引号后面的 / 不能少(去除首个换行符); 左边的两个空格的缩进不能变,否则会语法错误
extra: `` // 额外的配置,可以看 ob 的那个,需要一个 config 字段引入 init.sql
}
}
```
5. init.mjs 读入 vector 配置
```json
{ // 这是个块作用域, 直接搜 read in Vectors
// read in Vectors
// pg, ob ....
const vectordb = fs.readFileSync(path.join(process.cwd(), 'templates', 'vector', 'vector.txt'));
vector.vector.db = String(vectordb);
}
```
6. init.mjs 最后生成的时候,需要添加
```ts
fs.promises.writeFile(
path.join(process.cwd(), 'docker', 'cn', 'docker-compose.vector.yml'),
replace(template, 'cn', VectorEnum.vector)
),
fs.promises.writeFile(
path.join(process.cwd(), 'docker', 'global', 'docker-compose.ziliiz.yml'),
replace(template, 'global', VectorEnum.vector)
),
```

## yaml 的锚点和引用

`&` 标志一个锚点

```yaml
x-share-config: &x-share-config 'I am the config content'
x-share-config-list: &x-share-config-list
key1: value
key2: value
```

`*` 引用一个锚点
```yaml
some_other_example: *x-share-config-list
```
52 changes: 52 additions & 0 deletions deploy/args.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"tags": {
"fastgpt": "v4.13.0",
"fastgpt-sandbox": "v4.13.0",
"fastgpt-mcp_server": "v4.13.0",
"fastgpt-plugin": "v0.2.0",
"aiproxy": "v0.3.2",
"aiproxy-pg": "0.8.0-pg15",
"mongo": "5.0.18",
"redis": "7.2-alpine",
"minio": "RELEASE.2025-09-07T16-13-09Z",
"pg": "0.8.0-pg15",
"milvus-minio": "RELEASE.2023-03-20T20-16-18Z",
"milvus-etcd": "v3.5.5",
"milvus-standalone": "v2.4.3",
"oceanbase": "4.3.5-lts"
},
"images": {
"cn": {
"fastgpt": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt",
"fastgpt-plugin": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin",
"fastgpt-sandbox": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox",
"fastgpt-mcp_server": "registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server",
"aiproxy": "registry.cn-hangzhou.aliyuncs.com/labring/aiproxy",
"aiproxy-pg": "registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector",
"mongo": "registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo",
"redis": "redis",
"minio": "minio/minio",
"pg": "registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector",
"milvus-minio": "minio/minio",
"milvus-etcd": "quay.io/coreos/etcd",
"milvus-standalone": "milvusdb/milvus",
"oceanbase": "oceanbase/oceanbase-ce"
},
"global": {
"fastgpt": "ghcr.io/labring/fastgpt",
"fastgpt-plugin": "ghcr.io/labring/fastgpt-plugin",
"fastgpt-sandbox": "ghcr.io/labring/fastgpt-sandbox",
"fastgpt-mcp_server": "ghcr.io/labring/fastgpt-mcp_server",
"aiproxy": "ghcr.io/labring/aiproxy",
"aiproxy-pg": "pgvector/pgvector",
"mongo": "mongo",
"redis": "redis",
"minio": "minio/minio",
"pg": "pgvector/pgvector",
"milvus-minio": "minio/minio",
"milvus-etcd": "quay.io/coreos/etcd",
"milvus-standalone": "milvusdb/milvus",
"oceanbase": "oceanbase/oceanbase-ce"
}
}
}
4 changes: 4 additions & 0 deletions deploy/dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!.gitignore
!docker-compose.yml
!docker-compose.cn.yml
212 changes: 212 additions & 0 deletions deploy/dev/docker-compose.cn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# 用于开发的 docker-compose 文件:
# - 只包含 FastGPT 的最小化运行条件
# - 没有 FastGPT 本体
# - 所有端口都映射到外层
# - pg: 5432
# - mongo: 27017
# - redis: 6379
# - fastgpt-sandbox: 3002
# - fastgpt-plugin: 3003
# - aiproxy: 3010
# - 使用 pgvector 作为默认的向量库

services:
# Vector DB
pg:
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15
container_name: pg
restart: always
ports: # 生产环境建议不要暴露
- 5432:5432
networks:
- fastgpt
environment:
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgres
volumes:
- ./pg/data:/var/lib/postgresql/data
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'username', '-d', 'postgres']
interval: 5s
timeout: 5s
retries: 10

# DB
mongo:
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # cpu 不支持 AVX 时候使用 4.4.29
container_name: mongo
restart: always
ports:
- 27017:27017
networks:
- fastgpt
command: mongod --keyFile /data/mongodb.key --replSet rs0
environment:
- MONGO_INITDB_ROOT_USERNAME=myusername
- MONGO_INITDB_ROOT_PASSWORD=mypassword
volumes:
- ./mongo/data:/data/db
entrypoint:
- bash
- -c
- |
openssl rand -base64 128 > /data/mongodb.key
chmod 400 /data/mongodb.key
chown 999:999 /data/mongodb.key
echo 'const isInited = rs.status().ok === 1
if(!isInited){
rs.initiate({
_id: "rs0",
members: [
{ _id: 0, host: "mongo:27017" }
]
})
}' > /data/initReplicaSet.js
# 启动MongoDB服务
exec docker-entrypoint.sh "$$@" &

# 等待MongoDB服务启动
until mongo -u myusername -p mypassword --authenticationDatabase admin --eval "print('waited for connection')"; do
echo "Waiting for MongoDB to start..."
sleep 2
done

# 执行初始化副本集的脚本
mongo -u myusername -p mypassword --authenticationDatabase admin /data/initReplicaSet.js

# 等待docker-entrypoint.sh脚本执行的MongoDB服务进程
wait $$!
redis:
image: redis:7.2-alpine
container_name: redis
ports:
- 6379:6379
networks:
- fastgpt
restart: always
command: |
redis-server --requirepass mypassword --loglevel warning --maxclients 10000 --appendonly yes --save 60 10 --maxmemory 4gb --maxmemory-policy noeviction
healthcheck:
test: ['CMD', 'redis-cli', '-a', 'mypassword', 'ping']
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
volumes:
- ./redis/data:/data
fastgpt-minio:
image: minio/minio:RELEASE.2025-09-07T16-13-09Z
container_name: fastgpt-minio
restart: always
networks:
- fastgpt
ports:
- '9000:9000'
- '9001:9001'
environment:
- MINIO_ROOT_USER=minioadmin
- MINIO_ROOT_PASSWORD=minioadmin
volumes:
- ./fastgpt-minio:/data
command: server /data --console-address ":9001"
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
interval: 30s
timeout: 20s
retries: 3
sandbox:
container_name: sandbox
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.13.0
ports:
- 3002:3000
networks:
- fastgpt
restart: always
fastgpt-mcp-server:
container_name: fastgpt-mcp-server
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server:v4.13.0
ports:
- 3005:3000
networks:
- fastgpt
restart: always
environment:
- FASTGPT_ENDPOINT=http://fastgpt:3000
fastgpt-plugin:
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin:v0.2.0
container_name: fastgpt-plugin
restart: always
ports:
- 3003:3000
networks:
- fastgpt
environment:
- AUTH_TOKEN=token
- S3_ENDPOINT=fastgpt-minio
- S3_PORT=9000
- S3_USE_SSL=false
- S3_ACCESS_KEY=minioadmin
- S3_SECRET_KEY=minioadmin
- S3_BUCKET=fastgpt-plugins
- S3_TOOL_BUCKET=fastgpt-tool # 系统工具,创建的临时文件,存储的桶,要求公开读私有写。
- S3_PLUGIN_BUCKET=fastgpt-plugin # 系统插件热安装文件的桶,私有读写。
- RETENTION_DAYS=15 # 系统工具临时文件保存天数
- MONGODB_URI=mongodb://myusername:mypassword@mongo:27017/fastgpt?authSource=admin&directConnection=true
- REDIS_URL=redis://default:mypassword@redis:6379
depends_on:
fastgpt-minio:
condition: service_healthy
# AI Proxy
aiproxy:
image: registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:v0.3.2
container_name: aiproxy
restart: unless-stopped
ports:
- 3010:3000
depends_on:
aiproxy_pg:
condition: service_healthy
networks:
- fastgpt
- aiproxy
environment:
# 对应 fastgpt 里的AIPROXY_API_TOKEN
- ADMIN_KEY=aiproxy
# 错误日志详情保存时间(小时)
- LOG_DETAIL_STORAGE_HOURS=1
# 数据库连接地址
- SQL_DSN=postgres://postgres:aiproxy@aiproxy_pg:5432/aiproxy
# 最大重试次数
- RETRY_TIMES=3
# 不需要计费
- BILLING_ENABLED=false
# 不需要严格检测模型
- DISABLE_MODEL_CONFIG=true
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3000/api/status']
interval: 5s
timeout: 5s
retries: 10
aiproxy_pg:
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15 # docker hub
restart: unless-stopped
container_name: aiproxy_pg
volumes:
- ./aiproxy_pg:/var/lib/postgresql/data
networks:
- aiproxy
environment:
TZ: Asia/Shanghai
POSTGRES_USER: postgres
POSTGRES_DB: aiproxy
POSTGRES_PASSWORD: aiproxy
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'postgres', '-d', 'aiproxy']
interval: 5s
timeout: 5s
retries: 10
networks:
fastgpt:
aiproxy:
Loading
Loading