# 用于部署的 docker-compose 文件: # - FastGPT 端口映射为 3000:3000 # - FastGPT-mcp-server 端口映射 3005:3000 # - 建议修改账密后再运行 # root 默认密码(重启后会强制重置该密码成环境变量值) x-default-root-psw: &x-default-root-psw '1234' # FastGPT 前端访问地址,必须填写用户实际访问 FastGPT 的地址 x-fe-domain: &x-fe-domain '' # Sandbox Proxy WebSocket 地址,必须填写用户实际访问地址 x-agent-sandbox-proxy-url: &x-agent-sandbox-proxy-url '' # Sandbox Proxy HTTP 预览地址,必须填写用户实际访问地址 x-agent-sandbox-preview-proxy-url: &x-agent-sandbox-preview-proxy-url '' # 系统最高密钥凭证 x-system-key: &x-system-key 'fastgpt-xxx' # plugin auth token x-plugin-auth-token: &x-plugin-auth-token 'fastgpt_plugin_auth_token_32char' # code sandbox token x-code-sandbox-token: &x-code-sandbox-token 'codesandbox' # agent sandbox proxy secret,必须与 FastGPT 主站环境变量保持一致,且至少 32 位 x-agent-sandbox-proxy-secret: &x-agent-sandbox-proxy-secret 'default_fastgpt_agent_sandbox_proxy_secret' # volume manager token,必须与 FastGPT 主站环境变量保持一致 x-volume-manager-auth-token: &x-volume-manager-auth-token 'vmtoken' # aiproxy token x-aiproxy-token: &x-aiproxy-token 'token' # 数据库连接相关配置 x-share-db-config: &x-share-db-config MONGODB_URI: mongodb://myusername:mypassword@fastgpt-mongo:27017/fastgpt?authSource=admin DB_MAX_LINK: 100 REDIS_URL: redis://default:mypassword@fastgpt-redis:6379 # @see https://doc.fastgpt.cn/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_DOWNLOAD_URL_MODE: short-proxy # short-proxy | short-redirect STORAGE_S3_ENDPOINT: http://fastgpt-minio:9000 # 协议://域名(IP):端口 STORAGE_S3_FORCE_PATH_STYLE: true STORAGE_S3_MAX_RETRIES: 3 # Log 配置 x-log-config: &x-log-config LOG_ENABLE_CONSOLE: true LOG_CONSOLE_LEVEL: debug LOG_ENABLE_OTEL: false LOG_OTEL_LEVEL: info LOG_OTEL_URL: http://localhost:4318/v1/logs # 容器运行环境可能会自动注入 HTTP_PROXY/HTTPS_PROXY。 # 明确绕过 compose 内部服务,避免内部请求被代理劫持。 x-no-proxy-config: &x-no-proxy-config NO_PROXY: localhost,127.0.0.1,::1,fastgpt-app,fastgpt-plugin,fastgpt-code-sandbox,fastgpt-agent-sandbox-proxy,fastgpt-opensandbox-server,fastgpt-volume-manager,fastgpt-aiproxy,fastgpt-aiproxy-pg,fastgpt-minio,fastgpt-mongo,fastgpt-redis,fastgpt-vector,fastgpt-mcp-server,host.docker.internal,*.orb.internal,*.orb.local no_proxy: localhost,127.0.0.1,::1,fastgpt-app,fastgpt-plugin,fastgpt-code-sandbox,fastgpt-agent-sandbox-proxy,fastgpt-opensandbox-server,fastgpt-volume-manager,fastgpt-aiproxy,fastgpt-aiproxy-pg,fastgpt-minio,fastgpt-mongo,fastgpt-redis,fastgpt-vector,fastgpt-mcp-server,host.docker.internal,*.orb.internal,*.orb.local # FastGPT 主服务的 Agent Sandbox 配置 x-agent-sandbox-config: &x-agent-sandbox-config AGENT_SANDBOX_PROVIDER: opensandbox AGENT_SANDBOX_PROXY_SECRET: *x-agent-sandbox-proxy-secret # 浏览器访问 agent-sandbox-proxy 的 WebSocket 地址。 AGENT_SANDBOX_PROXY_URL: *x-agent-sandbox-proxy-url # 浏览器访问 Sandbox 文件预览的 HTTP(S) 地址。 AGENT_SANDBOX_PREVIEW_PROXY_URL: *x-agent-sandbox-preview-proxy-url # 沙盒规模大小 AGENT_SANDBOX_CPU_COUNT: 1 AGENT_SANDBOX_MEMORY_MIB: 2048 AGENT_SANDBOX_STORAGE_SIZE_GI: 1 # 不活跃判断阈值 AGENT_SANDBOX_SUSPEND_MINUTES: 60 # 长期不活跃判断阈值 AGENT_SANDBOX_ARCHIVE_INACTIVE_DAYS: 7 AGENT_SANDBOX_WS_MAX_MESSAGE_BYTES: 67108864 AGENT_SANDBOX_WS_MAX_FRAME_BYTES: 16777216 # 自定义 npm/pip 源 AGENT_SANDBOX_NPM_REGISTRY: AGENT_SANDBOX_PYPI_INDEX_URL: # Opensandox 配置 AGENT_SANDBOX_OPENSANDBOX_BASEURL: http://fastgpt-opensandbox-server:8090 AGENT_SANDBOX_OPENSANDBOX_API_KEY: fastgpt-opensandbox-api-key AGENT_SANDBOX_OPENSANDBOX_RUNTIME: docker AGENT_SANDBOX_OPENSANDBOX_IMAGE: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-agent-sandbox:v0.3.0-beta4 AGENT_SANDBOX_OPENSANDBOX_USE_SERVER_PROXY: true AGENT_SANDBOX_OPENSANDBOX_VOLUME_MANAGER_URL: http://fastgpt-volume-manager:3000 AGENT_SANDBOX_OPENSANDBOX_VOLUME_MANAGER_TOKEN: *x-volume-manager-auth-token AGENT_SANDBOX_OPENSANDBOX_VOLUME_NAME_PREFIX: fastgpt-session # Sealos devbox 配置 AGENT_SANDBOX_SEALOS_BASEURL: AGENT_SANDBOX_SEALOS_TOKEN: AGENT_SANDBOX_SEALOS_WORK_DIRECTORY: /home/devbox/workspace AGENT_SANDBOX_SEALOS_IMAGE: # 向量库相关配置 x-vec-config: &x-vec-config PG_URL: postgresql://username:password@fastgpt-vector:5432/postgres services: fastgpt-vector: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15 container_name: fastgpt-pg restart: always networks: - data environment: # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果 - POSTGRES_USER=username - POSTGRES_PASSWORD=password - POSTGRES_DB=postgres volumes: - fastgpt-pg:/var/lib/postgresql/data healthcheck: test: ['CMD', 'pg_isready', '-U', 'username', '-d', 'postgres'] interval: 5s timeout: 5s retries: 10 fastgpt-mongo: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.32 # cpu 不支持 AVX 时候使用 4.4.29 container_name: fastgpt-mongo restart: always networks: - data command: mongod --keyFile /data/mongodb.key --replSet rs0 environment: - MONGO_INITDB_ROOT_USERNAME=myusername - MONGO_INITDB_ROOT_PASSWORD=mypassword volumes: - fastgpt-mongo:/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: "fastgpt-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 $$! fastgpt-redis: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/redis:7.2-alpine container_name: fastgpt-redis networks: - data 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 fastgpt-minio: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/minio:RELEASE.2025-09-07T16-13-09Z container_name: fastgpt-minio restart: always ports: - 9000:9000 - 9001:9001 networks: - data 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-app: container_name: fastgpt-app image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.16.0-beta1 ports: - 3000:3000 networks: - data - app - codesandbox - aiproxy depends_on: fastgpt-mongo: condition: service_healthy fastgpt-vector: condition: service_healthy fastgpt-redis: condition: service_healthy fastgpt-minio: condition: service_healthy fastgpt-code-sandbox: condition: service_healthy fastgpt-plugin: condition: service_healthy restart: always environment: # 完整变量请参考: https://github.com/labring/FastGPT/blob/main/projects/app/.env.template <<: [*x-share-db-config, *x-vec-config, *x-log-config, *x-no-proxy-config, *x-agent-sandbox-config] HOSTNAME: 0.0.0.0 # ==================== 基础配置 ==================== # 必填。客户端访问 FastGPT 时使用的地址,由协议、主机和可选端口组成,用于补全文件资源路径。例如 https://fastgpt.cn;本地开发可使用 http://localhost:3000。 FE_DOMAIN: *x-fe-domain # root key(最高权限) ROOT_KEY: *x-system-key # root 密码,用户名为: root。如果需要修改 root 密码,直接修改这个环境变量,并重启即可。 DEFAULT_ROOT_PSW: *x-default-root-psw # 数据库最大连接数 DB_MAX_LINK: 5 # 自动同步索引 SYNC_INDEX: true # 系统变量替换等同步字符串处理的最大字符数,单位 M,范围 1~100 SYSTEM_MAX_STRING_LENGTH_M: 100 # 文件阅读时的密钥 FILE_TOKEN_KEY: filetokenkey # 密钥加密 key AES256_SECRET_KEY: fastgptsecret # Invoke 反向调用 JWT 密钥,至少 32 位 INVOKE_TOKEN_SECRET: fastgpt_invoke_token_secret_32_chars_min # 强制将图片转成 base64 传递给模型 MULTIPLE_DATA_TO_BASE64: false # ==================== 服务地址与集成 ==================== # plugin 地址 PLUGIN_BASE_URL: http://fastgpt-plugin:3000 PLUGIN_TOKEN: *x-plugin-auth-token # code-sandbox 地址 CODE_SANDBOX_URL: http://fastgpt-code-sandbox:3000 CODE_SANDBOX_TOKEN: *x-code-sandbox-token # AI Proxy 的地址,如果配了该地址,优先使用 AIPROXY_API_ENDPOINT: http://fastgpt-aiproxy:3000 # AI Proxy 的 Admin Token,与 AI Proxy 中的环境变量 ADMIN_KEY AIPROXY_API_TOKEN: *x-aiproxy-token PASSWORD_LOGIN_MINUTE_LIMIT_COUNT: # MCP Server 代理地址,用于 MCP 使用方式页拼接 SSE 地址 SSE_MCP_SERVER_PROXY_ENDPOINT: # ==================== 日志与监控 ==================== # 传递给 OTLP 收集器的服务名称 LOG_OTEL_SERVICE_NAME: fastgpt-client # ==================== 开源版特有配置,商业版这部分配置会在 admin 看板 ==================== # 知识库文件解析队列最大并发数 DATASET_PARSE_MAX_PROCESS: 10 # 向量训练队列最大并发数 VECTOR_MAX_PROCESS: 10 # 问答拆分队列最大并发数 QA_MAX_PROCESS: 10 # 图片理解模型处理队列最大并发数 VLM_MAX_PROCESS: 10 # 向量检索 hnsw ef_search 参数,仅对 PG / OB / OpenGauss 生效 HNSW_EF_SEARCH: 100 # 向量检索最大扫描数据量,仅对 PG 生效 HNSW_MAX_SCAN_TUPLES: 100000 # 自定义 PDF 解析服务配置 CUSTOM_PDF_PARSE_URL: CUSTOM_PDF_PARSE_KEY: # SoMark SOMARK_API_KEY: # Doc2x DOC2X_KEY: # 合合信息 TEXTIN_APP_ID: TEXTIN_SECRET_CODE: fastgpt-code-sandbox: container_name: fastgpt-code-sandbox image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-code-sandbox:v4.15.6 networks: - codesandbox restart: always security_opt: - no-new-privileges:true environment: <<: [*x-log-config, *x-no-proxy-config] LOG_OTEL_SERVICE_NAME: fastgpt-code-sandbox SANDBOX_TOKEN: *x-code-sandbox-token # ===== Resource Limits ===== # Maximum API JSON body size (MB), including variables SANDBOX_API_MAX_BODY_MB: 8 # Execution timeout per request (ms) SANDBOX_MAX_TIMEOUT: 60000 # Maximum allowed memory per user code execution (MB) # Note: System automatically adds 50MB for runtime overhead # Actual process limit = SANDBOX_MAX_MEMORY_MB + 50MB SANDBOX_MAX_MEMORY_MB: 256 SANDBOX_MAX_OUTPUT_MB: 10 # ===== Process Pool ===== # Number of pre-warmed worker processes (JS + Python) SANDBOX_POOL_SIZE: 20 # ===== Network Request Limits ===== # Whether to check if the request is to a private network CHECK_INTERNAL_IP: true # Maximum number of HTTP requests per execution SANDBOX_REQUEST_MAX_COUNT: 30 # Timeout for each outbound HTTP request (ms) SANDBOX_REQUEST_TIMEOUT: 60000 # Maximum response body size for outbound requests SANDBOX_REQUEST_MAX_RESPONSE_MB: 10 # Maximum request body size for outbound requests (MB) SANDBOX_REQUEST_MAX_BODY_MB: 5 # ===== Module Control ===== # JS allowed modules whitelist (comma-separated) SANDBOX_JS_ALLOWED_MODULES: lodash,dayjs,moment,uuid,crypto-js,qs,url,querystring # Python allowed modules whitelist (comma-separated) SANDBOX_PYTHON_ALLOWED_MODULES: math,cmath,decimal,fractions,random,statistics,collections,array,heapq,bisect,queue,copy,itertools,functools,operator,string,re,difflib,textwrap,unicodedata,codecs,datetime,time,calendar,_strptime,json,csv,base64,binascii,struct,hashlib,hmac,secrets,uuid,typing,abc,enum,dataclasses,contextlib,pprint,weakref,numpy,pandas,matplotlib healthcheck: test: [ 'CMD', 'node', '-e', "fetch('http://localhost:3000/health').then((res) => { if (!res.ok) throw new Error(String(res.status)); })" ] interval: 30s timeout: 20s retries: 3 fastgpt-mcp-server: container_name: fastgpt-mcp-server image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server:v4.14.23 networks: - app ports: - 3003:3000 restart: always environment: <<: [*x-log-config, *x-no-proxy-config] FASTGPT_ENDPOINT: http://fastgpt-app:3000 fastgpt-plugin: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin:v1.1.0-beta1 container_name: fastgpt-plugin restart: always networks: - data - app environment: <<: [*x-share-db-config, *x-log-config, *x-no-proxy-config] AUTH_TOKEN: *x-plugin-auth-token # 工具网络请求,最大请求和响应体 SERVICE_REQUEST_MAX_CONTENT_LENGTH: 10 # 最大 API 请求体大小 MAX_API_SIZE: 10 # 传递给 OTLP 收集器的服务名称 LOG_OTEL_SERVICE_NAME: fastgpt-plugin depends_on: fastgpt-mongo: condition: service_healthy fastgpt-minio: condition: service_healthy healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:3000/health'] interval: 30s timeout: 20s retries: 3 # OpenSandbox Server 和 Volume Manager 仅需在 app 内网中访问。 fastgpt-opensandbox-server: image: sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/server:v0.2.1 container_name: fastgpt-opensandbox-server restart: always networks: - app volumes: - /var/run/docker.sock:/var/run/docker.sock configs: - source: opensandbox-config target: /etc/opensandbox/config.toml environment: <<: [*x-no-proxy-config] SANDBOX_CONFIG_PATH: /etc/opensandbox/config.toml healthcheck: test: [ 'CMD', 'python', '-c', "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8090/health',timeout=3).status==200 else 1)" ] interval: 10s timeout: 5s retries: 5 fastgpt-volume-manager: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-agent-volume-manager:v0.3.0-beta4 container_name: fastgpt-volume-manager restart: always networks: - app volumes: - /var/run/docker.sock:/var/run/docker.sock:ro environment: <<: [*x-no-proxy-config] PORT: 3000 VM_RUNTIME: docker VM_AUTH_TOKEN: *x-volume-manager-auth-token VM_LOG_LEVEL: info healthcheck: test: [ 'CMD', 'node', '-e', "fetch('http://localhost:3000/health').then((res) => { if (!res.ok) process.exit(1); }).catch(() => process.exit(1));" ] interval: 10s timeout: 5s retries: 5 # 仅用于预拉取运行时镜像,不会随 docker compose up 启动。 opensandbox-agent-sandbox-image: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-agent-sandbox:v0.3.0-beta4 profiles: - prepull opensandbox-execd-image: image: sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/execd:v1.0.21 profiles: - prepull opensandbox-egress-image: image: sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/egress:v1.1.4 profiles: - prepull # 浏览器访问 Agent Sandbox 的鉴权代理,生产环境应通过独立域名反向代理 3006 端口。 fastgpt-agent-sandbox-proxy: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-agent-sandbox-proxy:v0.3.0-beta4 container_name: fastgpt-agent-sandbox-proxy restart: always networks: - app ports: - 3006:1006 environment: <<: [*x-no-proxy-config] PORT: 1006 AGENT_SANDBOX_PROXY_SECRET: *x-agent-sandbox-proxy-secret FASTGPT_APP_URL: http://fastgpt-app:3000 FASTGPT_APP_REQUEST_TIMEOUT_SECS: 60 RUST_LOG: info,fastgpt_agent_sandbox_proxy=debug # AI Proxy fastgpt-aiproxy: image: registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:v0.6.5 container_name: fastgpt-aiproxy restart: unless-stopped depends_on: fastgpt-aiproxy-pg: condition: service_healthy networks: - aiproxy environment: # 对应 fastgpt 里的AIPROXY_API_TOKEN ADMIN_KEY: *x-aiproxy-token # 错误日志详情保存时间(小时) LOG_DETAIL_STORAGE_HOURS: 1 # 数据库连接地址 SQL_DSN: postgres://postgres:aiproxy@fastgpt-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 fastgpt-aiproxy-pg: image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15 # docker hub restart: unless-stopped container_name: fastgpt-aiproxy-pg volumes: - fastgpt-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: data: name: fastgpt_data vector: name: fastgpt_vector app: name: fastgpt_app codesandbox: name: fastgpt_codesandbox aiproxy: name: fastgpt_aiproxy volumes: fastgpt-pg: fastgpt-mongo: fastgpt-redis: fastgpt-minio: fastgpt-milvus-minio: fastgpt-milvus-etcd: fastgpt-milvus-data: fastgpt-ob-data: fastgpt-ob-config: fastgpt-seekdb-data: fastgpt-seekdb-config: fastgpt-aiproxy_pg: configs: opensandbox-config: content: | [server] host = "0.0.0.0" port = 8090 api_key = "fastgpt-opensandbox-api-key" log_level = "INFO" [runtime] type = "docker" execd_image = "sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/execd:v1.0.21" [egress] image = "sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/egress:v1.1.4" [docker] network_mode = "bridge" host_ip = "host.docker.internal" [ingress] mode = "direct"