Documentation Index
Fetch the complete documentation index at: https://ai-gateway.juniortree.com/llms.txt
Use this file to discover all available pages before exploring further.
Docker部署
AI Gateway 支持使用Docker进行快速部署,这是推荐的部署方式。
快速部署
1. 构建镜像
# 克隆项目
git clone https://github.com/PancrePal-xiaoyibao/PancrePal-xiaoyibao.git
cd ai-gateway
# 构建Docker镜像
docker build -t ai-gateway .
2. 配置环境变量
创建 .env 文件并配置必要的环境变量:
# FastGPT配置
FASTGPT_BASE_URL=https://your-fastgpt-instance.com
FASTGPT_API_KEY=your-api-key
FASTGPT_APP_ID=your-app-id
# Dify配置
DIFY_BASE_URL=https://your-dify-instance.com
DIFY_API_KEY=your-api-key
# Coze配置
COZE_API_TOKEN=your-api-token
COZE_BOT_ID=your-bot-id
# S3/MinIO配置(可选)
S3_ENDPOINT=https://your-s3-endpoint.com
S3_ACCESS_KEY=your-access-key
S3_SECRET_KEY=your-secret-key
S3_BUCKET=your-bucket-name
S3_REGION=your-region
S3_KEY_PREFIX=uploads
S3_ACL=public-read
S3_PUBLIC_BASE_URL=https://your-cdn-domain.com
3. 运行容器
# 运行容器
docker run -d \
--name ai-gateway \
-p 3000:3000 \
--env-file .env \
ai-gateway
生产环境部署
使用Docker Compose
创建 docker-compose.yml 文件:
services:
app:
image: ghcr.io/liueic/pancrepal-xiaoyibao:latest
container_name: pancrepal-app
restart: unless-stopped
ports:
- "8000:8000"
environment:
# 数据库连接(容器内指向 mongo 服务)
MONGO_URI: ${MONGO_URI:-mongodb://mongo:27017}
MONGO_DATABASE: ${MONGO_DATABASE:-ai-gateway}
# 下列平台密钥建议在宿主机/CI 以环境变量注入
# DIFY_BASE_URL: ${DIFY_BASE_URL}
# DIFY_API_KEY: ${DIFY_API_KEY}
# FASTGPT_BASE_URL: ${FASTGPT_BASE_URL}
# FASTGPT_API_KEY: ${FASTGPT_API_KEY}
depends_on:
mongo:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8000/health"]
interval: 30s
timeout: 5s
retries: 5
networks:
- app-net
mongo:
image: mongo:7
container_name: pancrepal-mongo
restart: unless-stopped
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok" ]
interval: 30s
timeout: 5s
retries: 5
networks:
- app-net
volumes:
mongo-data:
networks:
app-net:
启动服务:
# 启动服务
docker compose up -d
# 查看日志
docker compose logs -f ai-gateway
# 停止服务
docker compose down
配置说明
端口配置
默认情况下,AI Gateway 监听8000端口。您可以通过修改 docker run 命令中的端口映射来更改:
# 使用其他端口
docker run -d -p 8080:8000 --env-file .env pancrepal-app
环境变量
必需配置
- FASTGPT_API_KEY 或 DIFY_API_KEY 或 COZE_API_TOKEN
- 对应的平台配置参数
可选配置
- S3/MinIO文件存储配置
- 日志级别配置
- 性能调优参数
健康检查
AI Gateway 提供健康检查端点:
# 检查服务状态
curl http://localhost:8000/health
# 预期响应
{
"status": "healthy",
"timestamp": "2024-01-15T10:30:00Z"
}
监控和日志
查看日志
# 查看容器日志
docker logs pancrepal-app
# 实时查看日志
docker logs -f pancrepal-app
# 查看最近100行日志
docker logs --tail 100 pancrepal-app
性能监控
# 查看容器资源使用情况
docker stats pancrepal-app
# 进入容器进行调试
docker exec -it pancrepal-app /bin/bash
更新部署
更新镜像
# 拉取最新代码
git pull
# 重新构建镜像
docker build -t pancrepal-app .
# 停止旧容器
docker stop pancrepal-app
# 删除旧容器
docker rm pancrepal-app
# 启动新容器
docker run -d --name pancrepal-app -p 8080:8000 --env-file .env pancrepal-app
使用Docker Compose更新
# 重新构建并启动
docker compose up -d --build
# 或者先停止再启动
docker compose down
docker-compose up -d --build
故障排除
常见问题
检查环境变量配置是否正确,特别是API密钥和URL格式。
确认AI平台的API密钥有效,网络连接正常。
检查S3/MinIO配置是否正确,存储桶是否存在。
调试命令
# 检查容器状态
docker ps -a
# 查看容器详细信息
docker inspect pancrepal-app
# 查看环境变量
docker exec pancrepal-app env
# 测试网络连接
docker exec pancrepal-app ping your-ai-platform.com
查看完整配置
了解更多关于AI Gateway的配置选项