1.环境准备:

安装Docker Ollama  git   python  能翻墙

2.在项目文件夹里创建两个文件

第一个是config.json

{
  "feConfigs": {
    "lafEnv": "https://laf.dev",
    "mcpServerProxyEndpoint": ""
  },
  "systemEnv": {
    "datasetParseMaxProcess": 10,
    "vectorMaxProcess": 10,
    "qaMaxProcess": 10,
    "vlmMaxProcess": 10,
    "tokenWorkers": 30,
    "hnswEfSearch": 100,
    "hnswMaxScanTuples": 100000,
    "customPdfParse": {
      "url": "",
      "key": "",
      "doc2xKey": "",
      "textinAppId": "",
      "textinSecretCode": "",
      "price": 0
    }
  }
}

第二个是docker-compose.yml

# 用于部署的 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: 100
  REDIS_URL: redis://default:mypassword@redis:6379
  # @see https://doc.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: http://192.168.0.2:9000 # 一个服务器和客户端均可访问到存储桶的地址,可以是固定的宿主机 IP 或者域名,注意不要填写成 127.0.0.1 或者 localhost 等本地回环地址(因为容器里无法使用)
  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

# 向量库相关配置
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.32 # 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
    ports:
      - 9000:9000
      - 9001:9001
    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.14.8 # git
    ports:
      - 3000:3000
    networks:
      - fastgpt
    depends_on:
      - mongo
      - sandbox
      - vectorDB
    restart: always
    environment:
      <<: [*x-share-db-config, *x-vec-config, *x-log-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

      # 传递给 OTLP 收集器的服务名称
      LOG_OTEL_SERVICE_NAME: fastgpt-client

      # 工作流最大运行次数
      WORKFLOW_MAX_RUN_TIMES: 1000
      # 批量执行节点,最大输入长度
      WORKFLOW_MAX_LOOP_TIMES: 100
      # 对话文件过期天数
      CHAT_FILE_EXPIRE_TIME: 7
      # 服务器接收请求,最大大小,单位 MB
      SERVICE_REQUEST_MAX_CONTENT_LENGTH: 10
      # HTML 转换最大字符数
      MAX_HTML_TRANSFORM_CHARS: 1000000
    volumes:
      - ./config.json:/app/data/config.json
  sandbox:
    container_name: sandbox
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.14.8
    networks:
      - fastgpt
    restart: always
  fastgpt-mcp-server:
    container_name: fastgpt-mcp-server
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server:v4.14.8
    networks:
      - fastgpt
    ports:
      - 3005:3000
    restart: always
    environment:
      <<: [*x-log-config]
      FASTGPT_ENDPOINT: http://fastgpt:3000
  fastgpt-plugin:
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin:v0.5.4
    container_name: fastgpt-plugin
    restart: always
    networks:
      - fastgpt
    environment:
      <<: [*x-share-db-config, *x-log-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-minio:
        condition: service_healthy
  # AI Proxy
  aiproxy:
    image: registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:v0.3.5
    container_name: aiproxy
    restart: unless-stopped
    ports:
      - 3002:3000
    depends_on:
      aiproxy_pg:
        condition: service_healthy
    networks:
      - fastgpt
      - aiproxy
    environment:
      # 对应 fastgpt 里的AIPROXY_API_TOKEN
      ADMIN_KEY: 12345678
      # 错误日志详情保存时间(小时)
      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:

3.Ollama拉取需要的大模型

因为我用的是qwen2:7b 和 bge-m3:latest,所以先用Ollama pull 进行拉取

ollama pull qwen2:7b
ollama pull bge-m3

4.拉取成功后,启动docker

拉取成功后,启动服务

docker-compose up -d

会在docker desktop界面containers中有 你的项目文件夹在运行,打开下拉三角,找到fastgpt 点击三个点,点击open in browser  打开fastgpt网页界面,

5.配置fastgpt

第一步 配置模型 ,找到左边的模型提供商,选择模型配置,点击新增模型,选择语言模型和索引模型配置

自定义请求地址填写http://host.docker.internal:11434/v1/chat/completions

http://host.docker.internal:11434/v1/embeddings

都点击确认后,退出此界面,找到左边的工作台,创建一个对话Agent,Ai配置里的ai模型选择刚才添加的qwen2:7b,还可以自己配一个知识库,就创建好一个属于自己的本地客服啦!!!!

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐