1022
This commit is contained in:
22
fastgpt/.env
Normal file
22
fastgpt/.env
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# PostgreSQL 配置
|
||||||
|
POSTGRES_PASSWORD=fastgpt_password
|
||||||
|
|
||||||
|
# MongoDB 配置
|
||||||
|
MONGO_USERNAME=root
|
||||||
|
MONGO_PASSWORD=fastgpt_mongo_password
|
||||||
|
|
||||||
|
# OpenAI API 配置(必需)
|
||||||
|
OPENAI_API_KEY=sk-fake_key_for_local_testing_only
|
||||||
|
OPENAI_BASE_URL=https://api.openai.com/v1
|
||||||
|
|
||||||
|
# 安全配置
|
||||||
|
JWT_SECRET=your_jwt_secret_key_here_please_change_in_production
|
||||||
|
APIKEY=your_api_key_here_please_change_in_production
|
||||||
|
FILE_TOKEN_KEY=your_file_token_key_here_please_change_in_production
|
||||||
|
|
||||||
|
# 系统配置
|
||||||
|
VECTOR_MAX_PROCESS=10
|
||||||
|
QA_MAX_PROCESS=10
|
||||||
|
|
||||||
|
# 默认管理员账号(首次登录使用)
|
||||||
|
DEFAULT_ROOT_PSW=admin123
|
||||||
29
fastgpt/.env.example
Normal file
29
fastgpt/.env.example
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# PostgreSQL 配置
|
||||||
|
POSTGRES_PASSWORD=your_postgres_password_here
|
||||||
|
|
||||||
|
# MongoDB 配置
|
||||||
|
MONGO_USERNAME=root
|
||||||
|
MONGO_PASSWORD=your_mongo_password_here
|
||||||
|
|
||||||
|
# OpenAI API 配置(必需)
|
||||||
|
OPENAI_API_KEY=your_openai_api_key_here
|
||||||
|
OPENAI_BASE_URL=https://api.openai.com/v1
|
||||||
|
|
||||||
|
# Claude API 配置(可选)
|
||||||
|
CLAUDE_API_KEY=your_claude_api_key_here
|
||||||
|
CLAUDE_BASE_URL=https://api.anthropic.com
|
||||||
|
|
||||||
|
# 安全配置
|
||||||
|
JWT_SECRET=your_jwt_secret_here_32_chars_min
|
||||||
|
APIKEY=your_api_key_here
|
||||||
|
FILE_TOKEN_KEY=your_file_token_key_here
|
||||||
|
SESSION_SECRET=your_session_secret_here
|
||||||
|
|
||||||
|
# 系统配置
|
||||||
|
SHARE_USER_ID=
|
||||||
|
SUB_PLANS=
|
||||||
|
VECTOR_MAX_PROCESS=10
|
||||||
|
QA_MAX_PROCESS=10
|
||||||
|
|
||||||
|
# 默认管理员账号(首次登录使用)
|
||||||
|
DEFAULT_ROOT_PSW=your_admin_password_here
|
||||||
136
fastgpt/README.md
Normal file
136
fastgpt/README.md
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
# FastGPT Docker 部署指南
|
||||||
|
|
||||||
|
FastGPT 是一个基于大语言模型的知识库问答系统,提供开箱即用的数据处理、模型调用等能力。
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 1. 创建目录并进入
|
||||||
|
```bash
|
||||||
|
mkdir fastgpt && cd fastgpt
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 下载配置文件
|
||||||
|
```bash
|
||||||
|
# 复制 docker-compose.yml 文件
|
||||||
|
cp /mnt/e/020-awei-cloud-9900k-code/common-server-public/fastgpt/docker-compose.yml .
|
||||||
|
|
||||||
|
# 复制环境变量文件
|
||||||
|
cp /mnt/e/020-awei-cloud-9900k-code/common-server-public/fastgpt/.env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 配置环境变量
|
||||||
|
编辑 `.env` 文件,设置必要的配置:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 必需配置
|
||||||
|
POSTGRES_PASSWORD=your_secure_postgres_password
|
||||||
|
MONGO_PASSWORD=your_secure_mongo_password
|
||||||
|
OPENAI_API_KEY=your_openai_api_key_here
|
||||||
|
JWT_SECRET=your_very_long_jwt_secret_key_here
|
||||||
|
APIKEY=your_api_key_here
|
||||||
|
FILE_TOKEN_KEY=your_file_token_key_here
|
||||||
|
|
||||||
|
# 默认管理员密码
|
||||||
|
DEFAULT_ROOT_PSW=your_admin_password
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 启动服务
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 访问 FastGPT
|
||||||
|
- FastGPT 主应用:http://localhost:3000
|
||||||
|
|
||||||
|
默认管理员账号:
|
||||||
|
- 用户名:root
|
||||||
|
- 密码:您在 `.env` 中设置的 `DEFAULT_ROOT_PSW`
|
||||||
|
|
||||||
|
## 服务说明
|
||||||
|
|
||||||
|
### 核心服务
|
||||||
|
- **FastGPT**: 主应用服务(端口 3000)
|
||||||
|
- **PostgreSQL**: 数据库服务,支持 pgvector 向量搜索
|
||||||
|
- **MongoDB**: 文档数据库
|
||||||
|
- **Redis**: 缓存服务
|
||||||
|
|
||||||
|
### 数据持久化
|
||||||
|
- PostgreSQL 数据:`postgres_data`
|
||||||
|
- MongoDB 数据:`mongo_data`
|
||||||
|
- Redis 数据:`redis_data`
|
||||||
|
|
||||||
|
## 配置说明
|
||||||
|
|
||||||
|
### 必需环境变量
|
||||||
|
- `OPENAI_API_KEY`: OpenAI API 密钥
|
||||||
|
- `POSTGRES_PASSWORD`: PostgreSQL 数据库密码
|
||||||
|
- `MONGO_PASSWORD`: MongoDB 数据库密码
|
||||||
|
- `JWT_SECRET`: JWT 密钥,用于用户认证
|
||||||
|
- `APIKEY`: FastGPT API 密钥
|
||||||
|
- `FILE_TOKEN_KEY`: 文件上传令牌密钥
|
||||||
|
|
||||||
|
### 可选配置
|
||||||
|
- `CLAUDE_API_KEY`: Claude API 密钥(可选)
|
||||||
|
- `VECTOR_MAX_PROCESS`: 向量处理最大进程数(默认 10)
|
||||||
|
- `QA_MAX_PROCESS`: 问答处理最大进程数(默认 10)
|
||||||
|
|
||||||
|
## 常用命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动服务
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# 停止服务
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# 查看日志
|
||||||
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# 重启服务
|
||||||
|
docker-compose restart
|
||||||
|
|
||||||
|
# 更新镜像
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## 功能特性
|
||||||
|
|
||||||
|
- 📚 知识库管理
|
||||||
|
- 🔍 智能问答
|
||||||
|
- 📄 文档处理
|
||||||
|
- 🎯 向量搜索
|
||||||
|
- 🔗 多模型支持(OpenAI、Claude 等)
|
||||||
|
- 📊 可视化工作流
|
||||||
|
- 👥 多用户管理
|
||||||
|
- 🔐 API 管理
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
1. **安全性**: 生产环境请使用强密码和密钥
|
||||||
|
2. **端口冲突**: 确保端口 3000、5432、27017、6379 未被占用
|
||||||
|
3. **资源要求**: 建议至少 4GB 内存,8GB 以上更佳
|
||||||
|
4. **备份**: 定期备份数据库数据
|
||||||
|
|
||||||
|
## 故障排查
|
||||||
|
|
||||||
|
### 服务无法启动
|
||||||
|
```bash
|
||||||
|
# 检查容器状态
|
||||||
|
docker-compose ps
|
||||||
|
|
||||||
|
# 查看具体服务日志
|
||||||
|
docker-compose logs [service-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 数据库连接失败
|
||||||
|
确保 PostgreSQL 和 MongoDB 服务正常启动,检查环境变量配置是否正确。
|
||||||
|
|
||||||
|
### API 调用失败
|
||||||
|
检查 `OPENAI_API_KEY` 是否有效,以及 API 配额是否充足。
|
||||||
|
|
||||||
|
## 更多帮助
|
||||||
|
|
||||||
|
- FastGPT 官方文档:https://doc.fastgpt.in/
|
||||||
|
- GitHub 仓库:https://github.com/labring/FastGPT
|
||||||
|
- 社区支持:https://github.com/labring/FastGPT/issues
|
||||||
22
fastgpt/config.json
Normal file
22
fastgpt/config.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"feConfigs": {
|
||||||
|
"lafEnv": "https://laf.dev", // laf环境。 https://laf.run (杭州阿里云) ,或者私有化的laf环境。如果使用 Laf openapi 功能,需要最新版的 laf 。
|
||||||
|
"mcpServerProxyEndpoint": "" // mcp server 代理地址,例如: http://localhost:3005
|
||||||
|
},
|
||||||
|
"systemEnv": {
|
||||||
|
"datasetParseMaxProcess": 10, // 知识库文件解析最大线程数量
|
||||||
|
"vectorMaxProcess": 10, // 向量处理线程数量
|
||||||
|
"qaMaxProcess": 10, // 问答拆分线程数量
|
||||||
|
"vlmMaxProcess": 10, // 图片理解模型最大处理进程
|
||||||
|
"tokenWorkers": 30, // Token 计算线程保持数,会持续占用内存,不能设置太大。
|
||||||
|
"hnswEfSearch": 100, // 向量搜索参数,仅对 PG 和 OB 生效。越大,搜索越精确,但是速度越慢。设置为100,有99%+精度。
|
||||||
|
"hnswMaxScanTuples": 100000, // 向量搜索最大扫描数据量,仅对 PG生效。
|
||||||
|
"customPdfParse": {
|
||||||
|
"url": "", // 自定义 PDF 解析服务地址
|
||||||
|
"key": "", // 自定义 PDF 解析服务密钥
|
||||||
|
"doc2xKey": "", // doc2x 服务密钥
|
||||||
|
"price": 0 // PDF 解析服务价格
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
267
fastgpt/docker-compose.yml
Normal file
267
fastgpt/docker-compose.yml
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
# 用于部署的 docker-compose 文件:
|
||||||
|
# - FastGPT 端口映射为 3000:3000
|
||||||
|
# - FastGPT-mcp-server 端口映射 3005:3000
|
||||||
|
# - 建议修改账密后再运行
|
||||||
|
|
||||||
|
# plugin auth token
|
||||||
|
x-plugin-auth-token: &x-plugin-auth-token 'token'
|
||||||
|
# aiproxy token
|
||||||
|
x-aiproxy-token: &x-aiproxy-token 'token'
|
||||||
|
# 数据库连接相关配置
|
||||||
|
x-share-db-config: &x-share-db-config
|
||||||
|
MONGODB_URI: mongodb://myusername:mypassword@mongo:27017/fastgpt?authSource=admin
|
||||||
|
DB_MAX_LINK: 30
|
||||||
|
REDIS_URL: redis://default:mypassword@redis:6379
|
||||||
|
S3_EXTERNAL_BASE_URL:
|
||||||
|
S3_ENDPOINT: fastgpt-minio
|
||||||
|
S3_PORT: 9000
|
||||||
|
S3_USE_SSL: false
|
||||||
|
S3_ACCESS_KEY: minioadmin
|
||||||
|
S3_SECRET_KEY: minioadmin
|
||||||
|
S3_PUBLIC_BUCKET: fastgpt-public # 公开读私有写桶
|
||||||
|
S3_PRIVATE_BUCKET: fastgpt-private # 私有读写桶
|
||||||
|
|
||||||
|
# 向量库相关配置
|
||||||
|
x-vec-config: &x-vec-config
|
||||||
|
PG_URL: postgresql://username:password@pg:5432/postgres
|
||||||
|
|
||||||
|
version: '3.3'
|
||||||
|
services:
|
||||||
|
# Vector DB
|
||||||
|
vectorDB:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15
|
||||||
|
container_name: pg
|
||||||
|
restart: always
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # cpu 不支持 AVX 时候使用 4.4.29
|
||||||
|
container_name: mongo
|
||||||
|
restart: always
|
||||||
|
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
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD', 'mongo', '-u', 'myusername', '-p', 'mypassword', '--authenticationDatabase', 'admin', '--eval', "db.adminCommand('ping')"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_period: 30s
|
||||||
|
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: registry.cn-hangzhou.aliyuncs.com/fastgpt/redis:7.2-alpine
|
||||||
|
container_name: redis
|
||||||
|
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: registry.cn-hangzhou.aliyuncs.com/fastgpt/minio:RELEASE.2025-09-07T16-13-09Z
|
||||||
|
container_name: fastgpt-minio
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- fastgpt
|
||||||
|
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
|
||||||
|
|
||||||
|
fastgpt:
|
||||||
|
container_name: fastgpt
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.13.2 # git
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
networks:
|
||||||
|
- fastgpt
|
||||||
|
depends_on:
|
||||||
|
- mongo
|
||||||
|
- sandbox
|
||||||
|
- vectorDB
|
||||||
|
- fastgpt-plugin
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
<<: [*x-share-db-config, *x-vec-config]
|
||||||
|
# 前端外部可访问的地址,用于自动补全文件资源路径。例如 https:fastgpt.cn,不能填 localhost。这个值可以不填,不填则发给模型的图片会是一个相对路径,而不是全路径,模型可能伪造Host。
|
||||||
|
FE_DOMAIN:
|
||||||
|
# root 密码,用户名为: root。如果需要修改 root 密码,直接修改这个环境变量,并重启即可。
|
||||||
|
DEFAULT_ROOT_PSW: 1234
|
||||||
|
# 登录凭证密钥
|
||||||
|
TOKEN_KEY: any
|
||||||
|
# root的密钥,常用于升级时候的初始化请求
|
||||||
|
ROOT_KEY: root_key
|
||||||
|
# 文件阅读加密
|
||||||
|
FILE_TOKEN_KEY: filetoken
|
||||||
|
# 密钥加密key
|
||||||
|
AES256_SECRET_KEY: fastgptkey
|
||||||
|
|
||||||
|
# plugin 地址
|
||||||
|
PLUGIN_BASE_URL: http://fastgpt-plugin:3000
|
||||||
|
PLUGIN_TOKEN: *x-plugin-auth-token
|
||||||
|
# sandbox 地址
|
||||||
|
SANDBOX_URL: http://sandbox:3000
|
||||||
|
# AI Proxy 的地址,如果配了该地址,优先使用
|
||||||
|
AIPROXY_API_ENDPOINT: http://aiproxy:3000
|
||||||
|
# AI Proxy 的 Admin Token,与 AI Proxy 中的环境变量 ADMIN_KEY
|
||||||
|
AIPROXY_API_TOKEN: *x-aiproxy-token
|
||||||
|
|
||||||
|
# 日志等级: debug, info, warn, error
|
||||||
|
LOG_LEVEL: info
|
||||||
|
STORE_LOG_LEVEL: warn
|
||||||
|
# 工作流最大运行次数
|
||||||
|
WORKFLOW_MAX_RUN_TIMES: 1000
|
||||||
|
# 批量执行节点,最大输入长度
|
||||||
|
WORKFLOW_MAX_LOOP_TIMES: 100
|
||||||
|
# 对话文件过期天数
|
||||||
|
CHAT_FILE_EXPIRE_TIME: 7
|
||||||
|
# 服务器接收请求,最大大小,单位 MB
|
||||||
|
SERVICE_REQUEST_MAX_CONTENT_LENGTH: 10
|
||||||
|
volumes:
|
||||||
|
- ./config.json:/app/data/config.json
|
||||||
|
sandbox:
|
||||||
|
container_name: sandbox
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.13.2
|
||||||
|
networks:
|
||||||
|
- fastgpt
|
||||||
|
restart: always
|
||||||
|
fastgpt-mcp-server:
|
||||||
|
container_name: fastgpt-mcp-server
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server:v4.13.2
|
||||||
|
networks:
|
||||||
|
- fastgpt
|
||||||
|
ports:
|
||||||
|
- 3006:3000
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- FASTGPT_ENDPOINT=http://fastgpt:3000
|
||||||
|
fastgpt-plugin:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin:v0.2.4
|
||||||
|
container_name: fastgpt-plugin
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- fastgpt
|
||||||
|
environment:
|
||||||
|
<<: *x-share-db-config
|
||||||
|
AUTH_TOKEN: *x-plugin-auth-token
|
||||||
|
S3_BUCKET: fastgpt-plugins
|
||||||
|
# 工具网络请求,最大请求和响应体
|
||||||
|
SERVICE_REQUEST_MAX_CONTENT_LENGTH: 10
|
||||||
|
# 最大 API 请求体大小
|
||||||
|
MAX_API_SIZE: 10
|
||||||
|
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
|
||||||
|
depends_on:
|
||||||
|
aiproxy_pg:
|
||||||
|
condition: service_healthy
|
||||||
|
networks:
|
||||||
|
- fastgpt
|
||||||
|
- aiproxy
|
||||||
|
environment:
|
||||||
|
# 对应 fastgpt 里的AIPROXY_API_TOKEN
|
||||||
|
ADMIN_KEY: *x-aiproxy-token
|
||||||
|
# 错误日志详情保存时间(小时)
|
||||||
|
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:
|
||||||
|
vector:
|
||||||
153
fastgpt/start.sh
Normal file
153
fastgpt/start.sh
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# FastGPT 管理脚本
|
||||||
|
# 用于快速管理 FastGPT 服务的启动、停止、重启等操作
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
# 颜色输出
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# 函数:显示帮助信息
|
||||||
|
show_help() {
|
||||||
|
echo "FastGPT 管理脚本"
|
||||||
|
echo "用法: $0 {start|stop|restart|status|logs|update|clean|backup}"
|
||||||
|
echo ""
|
||||||
|
echo "命令说明:"
|
||||||
|
echo " start - 启动 FastGPT 服务"
|
||||||
|
echo " stop - 停止 FastGPT 服务"
|
||||||
|
echo " restart - 重启 FastGPT 服务"
|
||||||
|
echo " status - 查看服务状态"
|
||||||
|
echo " logs - 查看实时日志"
|
||||||
|
echo " update - 更新镜像并重启"
|
||||||
|
echo " clean - 清理未使用的镜像和容器"
|
||||||
|
echo " backup - 备份数据库"
|
||||||
|
echo " help - 显示此帮助信息"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:检查环境
|
||||||
|
check_env() {
|
||||||
|
if [ ! -f ".env" ]; then
|
||||||
|
echo -e "${YELLOW}警告: .env 文件不存在,将使用默认配置${NC}"
|
||||||
|
echo -e "${YELLOW}建议复制 .env.example 为 .env 并进行配置${NC}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:启动服务
|
||||||
|
start() {
|
||||||
|
echo -e "${GREEN}正在启动 FastGPT 服务...${NC}"
|
||||||
|
check_env
|
||||||
|
docker-compose up -d
|
||||||
|
echo -e "${GREEN}FastGPT 服务已启动!${NC}"
|
||||||
|
echo -e "${GREEN}访问地址: http://localhost:3000${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:停止服务
|
||||||
|
stop() {
|
||||||
|
echo -e "${YELLOW}正在停止 FastGPT 服务...${NC}"
|
||||||
|
docker-compose down
|
||||||
|
echo -e "${YELLOW}FastGPT 服务已停止${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:重启服务
|
||||||
|
restart() {
|
||||||
|
echo -e "${GREEN}正在重启 FastGPT 服务...${NC}"
|
||||||
|
docker-compose restart
|
||||||
|
echo -e "${GREEN}FastGPT 服务已重启!${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:查看状态
|
||||||
|
status() {
|
||||||
|
echo -e "${GREEN}FastGPT 服务状态:${NC}"
|
||||||
|
docker-compose ps
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}容器资源使用情况:${NC}"
|
||||||
|
docker stats --no-stream $(docker-compose ps -q) 2>/dev/null || echo "容器未运行"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:查看日志
|
||||||
|
logs() {
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
# 查看特定服务的日志
|
||||||
|
docker-compose logs -f "$2"
|
||||||
|
else
|
||||||
|
# 查看所有日志
|
||||||
|
docker-compose logs -f
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:更新镜像
|
||||||
|
update() {
|
||||||
|
echo -e "${GREEN}正在更新 FastGPT 镜像...${NC}"
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
echo -e "${GREEN}镜像更新完成!${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:清理系统
|
||||||
|
clean() {
|
||||||
|
echo -e "${YELLOW}正在清理未使用的 Docker 资源...${NC}"
|
||||||
|
docker system prune -f
|
||||||
|
echo -e "${GREEN}清理完成!${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 函数:备份数据库
|
||||||
|
backup() {
|
||||||
|
BACKUP_DIR="./backups"
|
||||||
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||||
|
|
||||||
|
echo -e "${GREEN}正在备份数据库...${NC}"
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
# 备份 PostgreSQL
|
||||||
|
docker-compose exec -T postgres pg_dump -U postgres fastgpt > "$BACKUP_DIR/postgres_backup_$TIMESTAMP.sql"
|
||||||
|
|
||||||
|
# 备份 MongoDB
|
||||||
|
docker-compose exec -T mongo mongodump --username root --authenticationDatabase admin --db fastgpt --archive="/tmp/mongo_backup_$TIMESTAMP.archive" && \
|
||||||
|
docker-compose cp mongo:"/tmp/mongo_backup_$TIMESTAMP.archive" "$BACKUP_DIR/mongo_backup_$TIMESTAMP.archive" && \
|
||||||
|
docker-compose exec -T mongo rm "/tmp/mongo_backup_$TIMESTAMP.archive"
|
||||||
|
|
||||||
|
echo -e "${GREEN}数据库备份完成!备份文件保存在 $BACKUP_DIR${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 主程序
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
restart
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
logs)
|
||||||
|
logs "$@"
|
||||||
|
;;
|
||||||
|
update)
|
||||||
|
update
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
clean
|
||||||
|
;;
|
||||||
|
backup)
|
||||||
|
backup
|
||||||
|
;;
|
||||||
|
help|--help|-h)
|
||||||
|
show_help
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "${RED}错误: 未知命令 $1${NC}"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
38
nginx/conf.d/fastgpt.conf
Normal file
38
nginx/conf.d/fastgpt.conf
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name fastgpt.deepseak.icu;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://10.0.3.14:3000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
# 添加代理超时配置
|
||||||
|
proxy_connect_timeout 60s;
|
||||||
|
proxy_read_timeout 600s;
|
||||||
|
proxy_send_timeout 600s;
|
||||||
|
|
||||||
|
# 支持大文件上传和API请求
|
||||||
|
client_max_body_size 100M;
|
||||||
|
proxy_buffering off;
|
||||||
|
|
||||||
|
# 启用gzip压缩
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types
|
||||||
|
text/plain
|
||||||
|
text/css
|
||||||
|
text/xml
|
||||||
|
text/javascript
|
||||||
|
application/json
|
||||||
|
application/javascript
|
||||||
|
application/xml+rss
|
||||||
|
application/atom+xml
|
||||||
|
image/svg+xml;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ server {
|
|||||||
server_name membank.deepseak.icu;
|
server_name membank.deepseak.icu;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://127.0.0.1:10001;
|
proxy_pass http://10.0.3.14:10001;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ http {
|
|||||||
client_max_body_size 5m;
|
client_max_body_size 5m;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://127.0.0.1:3003;
|
proxy_pass http://10.0.3.14:3003;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@@ -84,7 +84,7 @@ http {
|
|||||||
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://127.0.0.1:3004;
|
proxy_pass http://10.0.3.14:3004;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@@ -99,7 +99,7 @@ http {
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name gitea.deepseak.icu;
|
server_name gitea.deepseak.icu;
|
||||||
|
client_max_body_size 200m;
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://10.0.3.14:3002;
|
proxy_pass http://10.0.3.14:3002;
|
||||||
# 添加代理超时配置
|
# 添加代理超时配置
|
||||||
@@ -115,7 +115,7 @@ http {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
}
|
}
|
||||||
client_max_body_size 50m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 增加一个空的server,用于申请证书
|
# 增加一个空的server,用于申请证书
|
||||||
|
|||||||
Reference in New Issue
Block a user