mirror of
https://github.com/labring/FastGPT.git
synced 2026-03-31 01:01:55 +08:00
- Add opensandbox-server service with TOML config (runtime, egress, docker security settings) - Add volume-manager service for PVC/volume lifecycle management - Rename sandbox container to fastgpt-code-sandbox for consistency - Migrate all bind mounts (pg, mongo, redis, minio, aiproxy_pg) to Docker named volumes - Add healthcheck for fastgpt-code-sandbox service - Bump opensandbox-egress version from v1.0.1 to v1.0.3 - Update port comments to include opensandbox-server:8090 and volume-manager:3004
317 lines
9.0 KiB
YAML
317 lines
9.0 KiB
YAML
# 用于开发的 docker-compose 文件:
|
||
# - 只包含 FastGPT 的最小化运行条件
|
||
# - 没有 FastGPT 本体
|
||
# - 所有端口都映射到外层
|
||
# - pg: 5432
|
||
# - mongo: 27017
|
||
# - redis: 6379
|
||
# - fastgpt-code-sandbox: 3002
|
||
# - fastgpt-plugin: 3003
|
||
# - opensandbox-server: 8090
|
||
# - volume-manager: 3004
|
||
# - aiproxy: 3010
|
||
# - 使用 pgvector 作为默认的向量库
|
||
# - 配置 opensandbox-config 的 network_mode 为 docker 网络,如 dev_fastgpt
|
||
# - 配置 opensandbox-config 的 host_ip 为宿主机 LAN IP,如 192.168.1.100
|
||
|
||
configs:
|
||
opensandbox-config:
|
||
content: |
|
||
[server]
|
||
host = "0.0.0.0"
|
||
port = 8090
|
||
log_level = "INFO"
|
||
|
||
[runtime]
|
||
type = "docker"
|
||
execd_image = "opensandbox/execd:v1.0.7"
|
||
|
||
[egress]
|
||
image = "opensandbox/egress:v1.0.3"
|
||
|
||
[docker]
|
||
network_mode = "bridge"
|
||
# When server runs in a container, set host_ip to the host's IP or hostname so bridge-mode endpoints are reachable (e.g. host.docker.internal or the host LAN IP).
|
||
# It's required when server deployed with docker container under host.
|
||
host_ip = "host.docker.internal"
|
||
drop_capabilities = ["AUDIT_WRITE", "MKNOD", "NET_ADMIN", "NET_RAW", "SYS_ADMIN", "SYS_MODULE", "SYS_PTRACE", "SYS_TIME", "SYS_TTY_CONFIG"]
|
||
no_new_privileges = true
|
||
pids_limit = 512
|
||
|
||
[ingress]
|
||
mode = "direct"
|
||
|
||
services:
|
||
# Vector DB
|
||
pg:
|
||
image: pgvector/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:
|
||
- fastgpt-pg_data:/var/lib/postgresql/data
|
||
healthcheck:
|
||
test: ['CMD', 'pg_isready', '-U', 'username', '-d', 'postgres']
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
# DB
|
||
mongo:
|
||
image: mongo:5.0.32 # 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:
|
||
- fastgpt-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: 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:
|
||
- fastgpt-redis_data:/data
|
||
fastgpt-minio:
|
||
image: minio/minio:RELEASE.2025-09-07T16-13-09Z # cpu 不支持 AVX 时候使用 -cpuv1
|
||
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:/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-code-sandbox:
|
||
container_name: fastgpt-code-sandbox
|
||
image: ghcr.io/labring/fastgpt-sandbox:v4.14.8
|
||
ports:
|
||
- 3002:3000
|
||
networks:
|
||
- fastgpt
|
||
restart: always
|
||
fastgpt-mcp-server:
|
||
container_name: fastgpt-mcp-server
|
||
image: ghcr.io/labring/fastgpt-mcp_server:v4.14.8
|
||
ports:
|
||
- 3005:3000
|
||
networks:
|
||
- fastgpt
|
||
restart: always
|
||
environment:
|
||
- FASTGPT_ENDPOINT=http://fastgpt:3000
|
||
fastgpt-plugin:
|
||
image: ghcr.io/labring/fastgpt-plugin:v0.5.4
|
||
container_name: fastgpt-plugin
|
||
restart: always
|
||
ports:
|
||
- 3003:3000
|
||
networks:
|
||
- fastgpt
|
||
environment:
|
||
- AUTH_TOKEN=token
|
||
# @see https://fastgpt.cn/docs/self-host/config/object-storage
|
||
- STORAGE_VENDOR=minio # minio | aws-s3 | cos | oss
|
||
- STORAGE_REGION=us-east-1
|
||
- STORAGE_ACCESS_KEY_ID=minioadmin
|
||
- STORAGE_SECRET_ACCESS_KEY=minioadmin
|
||
- STORAGE_PUBLIC_BUCKET=fastgpt-public
|
||
- STORAGE_PRIVATE_BUCKET=fastgpt-private
|
||
- STORAGE_EXTERNAL_ENDPOINT=https://minio.com # 一个公开的、前端和用户可以直接访问的对象存储连接
|
||
- STORAGE_S3_ENDPOINT=http://fastgpt-minio:9000 # 协议://域名(IP):端口
|
||
- STORAGE_S3_FORCE_PATH_STYLE=true
|
||
- STORAGE_S3_MAX_RETRIES=3
|
||
- 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
|
||
healthcheck:
|
||
test: ['CMD', 'curl', '-f', 'http://localhost:3000/health']
|
||
interval: 30s
|
||
timeout: 20s
|
||
retries: 3
|
||
# AI Proxy
|
||
aiproxy:
|
||
image: ghcr.io/labring/aiproxy:v0.3.5
|
||
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: pgvector/pgvector:0.8.0-pg15 # docker hub
|
||
restart: unless-stopped
|
||
container_name: aiproxy_pg
|
||
volumes:
|
||
- fastgpt-aiproxy_pg_data:/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
|
||
opensandbox-server:
|
||
image: opensandbox/server:v0.1.7
|
||
container_name: opensandbox-server
|
||
restart: always
|
||
networks:
|
||
- fastgpt
|
||
ports:
|
||
- '8090:8090'
|
||
volumes:
|
||
- /var/run/docker.sock:/var/run/docker.sock
|
||
configs:
|
||
- source: opensandbox-config
|
||
target: /etc/opensandbox/config.toml
|
||
environment:
|
||
- SANDBOX_CONFIG_PATH=/etc/opensandbox/config.toml
|
||
healthcheck:
|
||
test: ['CMD', 'curl', '-f', 'http://localhost:8090/health']
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
volume-manager:
|
||
image: fastgpt-volume-manager:latest
|
||
container_name: volume-manager
|
||
restart: always
|
||
networks:
|
||
- fastgpt
|
||
ports:
|
||
- 3004:3001
|
||
volumes:
|
||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||
environment:
|
||
- VM_RUNTIME=docker
|
||
- VM_AUTH_TOKEN=changeme
|
||
- VM_VOLUME_NAME_PREFIX=fastgpt-session
|
||
- VM_LOG_LEVEL=info
|
||
healthcheck:
|
||
test:
|
||
['CMD', 'bun', '-e', "fetch('http://localhost:3001/health').then((res) => { if (!res.ok) throw new Error(String(res.status)); })"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
networks:
|
||
fastgpt:
|
||
aiproxy:
|
||
|
||
volumes:
|
||
fastgpt-pg_data:
|
||
fastgpt-mongo_data:
|
||
fastgpt-redis_data:
|
||
fastgpt-minio_data:
|
||
fastgpt-aiproxy_pg_data:
|