|
| 1 | +# 用于开发的 docker-compose 文件: |
| 2 | +# - 只包含 FastGPT 的最小化运行条件 |
| 3 | +# - 没有 FastGPT 本体 |
| 4 | +# - 所有端口都映射到外层 |
| 5 | +# - pg: 5432 |
| 6 | +# - mongo: 27017 |
| 7 | +# - redis: 6379 |
| 8 | +# - fastgpt-sandbox: 3002 |
| 9 | +# - fastgpt-plugin: 3003 |
| 10 | +# - aiproxy: 3010 |
| 11 | +# - 使用 pgvector 作为默认的向量库 |
| 12 | + |
| 13 | +services: |
| 14 | + # Vector DB |
| 15 | + pg: |
| 16 | + image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15 |
| 17 | + container_name: pg |
| 18 | + restart: always |
| 19 | + ports: # 生产环境建议不要暴露 |
| 20 | + - 5432:5432 |
| 21 | + networks: |
| 22 | + - fastgpt |
| 23 | + environment: |
| 24 | + # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果 |
| 25 | + - POSTGRES_USER=username |
| 26 | + - POSTGRES_PASSWORD=password |
| 27 | + - POSTGRES_DB=postgres |
| 28 | + volumes: |
| 29 | + - ./pg/data:/var/lib/postgresql/data |
| 30 | + healthcheck: |
| 31 | + test: ['CMD', 'pg_isready', '-U', 'username', '-d', 'postgres'] |
| 32 | + interval: 5s |
| 33 | + timeout: 5s |
| 34 | + retries: 10 |
| 35 | + |
| 36 | + # DB |
| 37 | + mongo: |
| 38 | + image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # cpu 不支持 AVX 时候使用 4.4.29 |
| 39 | + container_name: mongo |
| 40 | + restart: always |
| 41 | + ports: |
| 42 | + - 27017:27017 |
| 43 | + networks: |
| 44 | + - fastgpt |
| 45 | + command: mongod --keyFile /data/mongodb.key --replSet rs0 |
| 46 | + environment: |
| 47 | + - MONGO_INITDB_ROOT_USERNAME=myusername |
| 48 | + - MONGO_INITDB_ROOT_PASSWORD=mypassword |
| 49 | + volumes: |
| 50 | + - ./mongo/data:/data/db |
| 51 | + entrypoint: |
| 52 | + - bash |
| 53 | + - -c |
| 54 | + - | |
| 55 | + openssl rand -base64 128 > /data/mongodb.key |
| 56 | + chmod 400 /data/mongodb.key |
| 57 | + chown 999:999 /data/mongodb.key |
| 58 | + echo 'const isInited = rs.status().ok === 1 |
| 59 | + if(!isInited){ |
| 60 | + rs.initiate({ |
| 61 | + _id: "rs0", |
| 62 | + members: [ |
| 63 | + { _id: 0, host: "mongo:27017" } |
| 64 | + ] |
| 65 | + }) |
| 66 | + }' > /data/initReplicaSet.js |
| 67 | + # 启动MongoDB服务 |
| 68 | + exec docker-entrypoint.sh "$$@" & |
| 69 | +
|
| 70 | + # 等待MongoDB服务启动 |
| 71 | + until mongo -u myusername -p mypassword --authenticationDatabase admin --eval "print('waited for connection')"; do |
| 72 | + echo "Waiting for MongoDB to start..." |
| 73 | + sleep 2 |
| 74 | + done |
| 75 | +
|
| 76 | + # 执行初始化副本集的脚本 |
| 77 | + mongo -u myusername -p mypassword --authenticationDatabase admin /data/initReplicaSet.js |
| 78 | +
|
| 79 | + # 等待docker-entrypoint.sh脚本执行的MongoDB服务进程 |
| 80 | + wait $$! |
| 81 | + redis: |
| 82 | + image: redis:7.2-alpine |
| 83 | + container_name: redis |
| 84 | + ports: |
| 85 | + - 6379:6379 |
| 86 | + networks: |
| 87 | + - fastgpt |
| 88 | + restart: always |
| 89 | + command: | |
| 90 | + redis-server --requirepass mypassword --loglevel warning --maxclients 10000 --appendonly yes --save 60 10 --maxmemory 4gb --maxmemory-policy noeviction |
| 91 | + healthcheck: |
| 92 | + test: ['CMD', 'redis-cli', '-a', 'mypassword', 'ping'] |
| 93 | + interval: 10s |
| 94 | + timeout: 3s |
| 95 | + retries: 3 |
| 96 | + start_period: 30s |
| 97 | + volumes: |
| 98 | + - ./redis/data:/data |
| 99 | + fastgpt-minio: |
| 100 | + image: minio/minio:RELEASE.2025-09-07T16-13-09Z |
| 101 | + container_name: fastgpt-minio |
| 102 | + restart: always |
| 103 | + networks: |
| 104 | + - fastgpt |
| 105 | + ports: |
| 106 | + - '9000:9000' |
| 107 | + - '9001:9001' |
| 108 | + environment: |
| 109 | + - MINIO_ROOT_USER=minioadmin |
| 110 | + - MINIO_ROOT_PASSWORD=minioadmin |
| 111 | + volumes: |
| 112 | + - ./fastgpt-minio:/data |
| 113 | + command: server /data --console-address ":9001" |
| 114 | + healthcheck: |
| 115 | + test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live'] |
| 116 | + interval: 30s |
| 117 | + timeout: 20s |
| 118 | + retries: 3 |
| 119 | + sandbox: |
| 120 | + container_name: sandbox |
| 121 | + image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.13.0 |
| 122 | + ports: |
| 123 | + - 3002:3000 |
| 124 | + networks: |
| 125 | + - fastgpt |
| 126 | + restart: always |
| 127 | + fastgpt-mcp-server: |
| 128 | + container_name: fastgpt-mcp-server |
| 129 | + image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-mcp_server:v4.13.0 |
| 130 | + ports: |
| 131 | + - 3005:3000 |
| 132 | + networks: |
| 133 | + - fastgpt |
| 134 | + restart: always |
| 135 | + environment: |
| 136 | + - FASTGPT_ENDPOINT=http://fastgpt:3000 |
| 137 | + fastgpt-plugin: |
| 138 | + image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-plugin:v0.2.0 |
| 139 | + container_name: fastgpt-plugin |
| 140 | + restart: always |
| 141 | + ports: |
| 142 | + - 3003:3000 |
| 143 | + networks: |
| 144 | + - fastgpt |
| 145 | + environment: |
| 146 | + - AUTH_TOKEN=token |
| 147 | + - S3_ENDPOINT=fastgpt-minio |
| 148 | + - S3_PORT=9000 |
| 149 | + - S3_USE_SSL=false |
| 150 | + - S3_ACCESS_KEY=minioadmin |
| 151 | + - S3_SECRET_KEY=minioadmin |
| 152 | + - S3_BUCKET=fastgpt-plugins |
| 153 | + - S3_TOOL_BUCKET=fastgpt-tool # 系统工具,创建的临时文件,存储的桶,要求公开读私有写。 |
| 154 | + - S3_PLUGIN_BUCKET=fastgpt-plugin # 系统插件热安装文件的桶,私有读写。 |
| 155 | + - RETENTION_DAYS=15 # 系统工具临时文件保存天数 |
| 156 | + - MONGODB_URI=mongodb://myusername:mypassword@mongo:27017/fastgpt?authSource=admin&directConnection=true |
| 157 | + - REDIS_URL=redis://default:mypassword@redis:6379 |
| 158 | + depends_on: |
| 159 | + fastgpt-minio: |
| 160 | + condition: service_healthy |
| 161 | + # AI Proxy |
| 162 | + aiproxy: |
| 163 | + image: registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:v0.3.2 |
| 164 | + container_name: aiproxy |
| 165 | + restart: unless-stopped |
| 166 | + ports: |
| 167 | + - 3010:3000 |
| 168 | + depends_on: |
| 169 | + aiproxy_pg: |
| 170 | + condition: service_healthy |
| 171 | + networks: |
| 172 | + - fastgpt |
| 173 | + - aiproxy |
| 174 | + environment: |
| 175 | + # 对应 fastgpt 里的AIPROXY_API_TOKEN |
| 176 | + - ADMIN_KEY=aiproxy |
| 177 | + # 错误日志详情保存时间(小时) |
| 178 | + - LOG_DETAIL_STORAGE_HOURS=1 |
| 179 | + # 数据库连接地址 |
| 180 | + - SQL_DSN=postgres://postgres:aiproxy@aiproxy_pg:5432/aiproxy |
| 181 | + # 最大重试次数 |
| 182 | + - RETRY_TIMES=3 |
| 183 | + # 不需要计费 |
| 184 | + - BILLING_ENABLED=false |
| 185 | + # 不需要严格检测模型 |
| 186 | + - DISABLE_MODEL_CONFIG=true |
| 187 | + healthcheck: |
| 188 | + test: ['CMD', 'curl', '-f', 'http://localhost:3000/api/status'] |
| 189 | + interval: 5s |
| 190 | + timeout: 5s |
| 191 | + retries: 10 |
| 192 | + aiproxy_pg: |
| 193 | + image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:0.8.0-pg15 # docker hub |
| 194 | + restart: unless-stopped |
| 195 | + container_name: aiproxy_pg |
| 196 | + volumes: |
| 197 | + - ./aiproxy_pg:/var/lib/postgresql/data |
| 198 | + networks: |
| 199 | + - aiproxy |
| 200 | + environment: |
| 201 | + TZ: Asia/Shanghai |
| 202 | + POSTGRES_USER: postgres |
| 203 | + POSTGRES_DB: aiproxy |
| 204 | + POSTGRES_PASSWORD: aiproxy |
| 205 | + healthcheck: |
| 206 | + test: ['CMD', 'pg_isready', '-U', 'postgres', '-d', 'aiproxy'] |
| 207 | + interval: 5s |
| 208 | + timeout: 5s |
| 209 | + retries: 10 |
| 210 | +networks: |
| 211 | + fastgpt: |
| 212 | + aiproxy: |
0 commit comments