b7073d9c5b
- Update .env.example with production-ready environment variables - Add frontend Aliyun deployment configuration with nginx gateway - Refactor docker-compose.server.yml for external services - Add comprehensive deployment guide (docs/DEPLOYMENT.md) - Enhance troubleshooting documentation with Git Bash path issues - Add deployment scripts (build-frontend.sh, deploy-frontend.sh) - Add deploy directory with docker-compose and nginx config - Update .gitignore to exclude temporary directories Co-Authored-By: Claude <noreply@anthropic.com>
3.3 KiB
3.3 KiB
AI Contract Platform 部署说明
部署架构
与 hyburk.com 部署方式一致,采用前后端分离部署:
| 组件 | 部署位置 | 目录 | 说明 |
|---|---|---|---|
| 前端 Next.js | 阿里云 ECS | /opt/apps/ai-contract-web |
nginx gateway + Next.js 容器 |
| 后端 FastAPI | 192.168.3.90 | /opt/apps/ai-contract-platform |
backend + worker + redis |
| 后端 Gateway | 192.168.3.90 | /opt/apps/ai-contract-platform-gateway |
nginx 代理 API |
| 共享 PostgreSQL | 192.168.3.90 | - | 端口 5432 |
| 共享 Redis | 192.168.3.90 | - | 端口 6379 |
| 共享 MinIO | 192.168.3.90 | - | 端口 9000 |
域名: contact.yuqei.com
流量路径:
contact.yuqei.com → 阿里云 nginx (127.0.0.1:18083)
├── /api/ → 后端服务器 10.20.0.11:18083 → backend:8000
├── /health → 后端服务器 health check
└── 其他 → 阿里云 Next.js 容器:3000
配置文件说明
| 文件 | 用途 |
|---|---|
docker-compose.server.yml |
后端服务器部署(192.168.3.90) |
docker-compose.frontend.aliyun.yml |
前端阿里云部署模板 |
deploy/web-gateway.conf |
阿里云 nginx 配置(前端 gateway) |
.env.example |
后端环境变量模板 |
阿里云前端部署目录结构
/opt/apps/ai-contract-web/
├── releases/
│ └── YYYYMMDDHHMMSS/
│ ├── docker-compose.yml # 使用 docker-compose.frontend.aliyun.yml
│ ├── nginx/
│ │ └── web-gateway.conf # nginx 配置
│ └── app/ # 前端代码(从 frontend/ 复制)
│ ├── Dockerfile
│ └── ... (Next.js 项目文件)
├── current → releases/YYYYMMDDHHMMSS # 软链接指向当前版本
└── logs/
└── nginx/
后端服务器部署目录结构
/opt/apps/ai-contract-platform/
├── docker-compose.server.yml
├── .env
├── backend/
│ ├── Dockerfile
│ └── ... (FastAPI 项目文件)
└── frontend/ # 可选,本地开发用
部署步骤
1. 后端部署(192.168.3.90)
cd /opt/apps/ai-contract-platform
git pull
docker compose -f docker-compose.server.yml up -d --build
2. 前端部署(阿里云)
# 创建发布目录
TIMESTAMP=$(date +%Y%m%d%H%M%S)
mkdir -p /opt/apps/ai-contract-web/releases/$TIMESTAMP
cd /opt/apps/ai-contract-web/releases/$TIMESTAMP
# 复制配置和代码
cp docker-compose.yml . # 来自项目 docker-compose.frontend.aliyun.yml
mkdir -p nginx app
cp web-gateway.conf nginx/ # 来自项目 deploy/web-gateway.conf
cp -r frontend/* app/ # 复制前端代码
# 构建和启动
docker compose up -d --build
# 更新软链接
ln -sfn /opt/apps/ai-contract-web/releases/$TIMESTAMP /opt/apps/ai-contract-web/current
3. 验证
# 后端健康检查
curl http://10.20.0.11:18083/health
# 前端健康检查
curl http://127.0.0.1:18083/healthz
# 完整检查
curl http://contact.yuqei.com/health
端口说明
| 端口 | 服务 | 位置 |
|---|---|---|
| 18083 | 前端 nginx gateway | 阿里云 127.0.0.1 |
| 18083 | 后端 nginx gateway | 192.168.3.90 10.20.0.11 |
| 8001 | 后端 FastAPI | 192.168.3.90 |
| 5432 | PostgreSQL | 192.168.3.90 |
| 6379 | Redis | 192.168.3.90 |
| 9000 | MinIO | 192.168.3.90 |