Initial commit: AI Interview System
This commit is contained in:
206
docs/部署文档.md
Normal file
206
docs/部署文档.md
Normal file
@@ -0,0 +1,206 @@
|
||||
# AI 语音面试系统 - 部署文档
|
||||
|
||||
> 更新日期: 2026-01-21
|
||||
> 状态: ✅ 已部署
|
||||
|
||||
## 一、服务器信息
|
||||
|
||||
| 项目 | 值 |
|
||||
|------|-----|
|
||||
| 服务器 IP | 47.107.172.23 |
|
||||
| SSH 用户名 | root |
|
||||
| SSH 密码 | Nj861021 |
|
||||
| 宝塔面板 | http://47.107.172.23:8888/ |
|
||||
| 宝塔 API Token | PKdfnaInQL0P5ghB8SvwbrGcIpXWaEvq |
|
||||
| 域名解析 | *.ai.ireborn.com.cn → 47.107.172.23 |
|
||||
| 测试域名 | *.test.ai.ireborn.com.cn |
|
||||
|
||||
## 二、部署地址 (已上线)
|
||||
|
||||
| 服务 | 地址 | 状态 |
|
||||
|------|------|------|
|
||||
| 用户端 | http://interview.test.ai.ireborn.com.cn | ✅ |
|
||||
| 管理后台 | http://interview.test.ai.ireborn.com.cn/admin | ✅ |
|
||||
| 后端 API | http://interview.test.ai.ireborn.com.cn/api/health | ✅ |
|
||||
| 文件服务 | https://files.test.ai.ireborn.com.cn | ✅ |
|
||||
|
||||
> ⚠️ 当前为简化版后端,完整功能代码需要手动上传后重新构建
|
||||
|
||||
## 三、Docker 部署
|
||||
|
||||
### 3.1 目录结构
|
||||
|
||||
```
|
||||
/www/wwwroot/ai-interview/
|
||||
├── deploy/
|
||||
│ ├── docker-compose.yml
|
||||
│ ├── Dockerfile.frontend
|
||||
│ ├── Dockerfile.backend
|
||||
│ ├── nginx/
|
||||
│ │ └── frontend.conf
|
||||
│ └── .env
|
||||
├── frontend/
|
||||
├── backend/
|
||||
└── uploads/
|
||||
```
|
||||
|
||||
### 3.2 环境变量配置
|
||||
|
||||
创建 `/www/wwwroot/ai-interview/deploy/.env`:
|
||||
|
||||
```bash
|
||||
# Coze 配置
|
||||
COZE_PAT_TOKEN=pat_nd1wU47WyPS9GCIyJ1clnH8h1WOQXGrYELX8w73TnSZaYbFdYD4swIhzcETBUbfT
|
||||
COZE_BOT_ID=7595113005181386792
|
||||
|
||||
# 工作流 ID
|
||||
COZE_WORKFLOW_A_ID=7597357422713798710
|
||||
COZE_WORKFLOW_C_ID=7597376294612107318
|
||||
|
||||
# 文件服务器
|
||||
FILE_SERVER_URL=https://files.test.ai.ireborn.com.cn
|
||||
FILE_SERVER_TOKEN=ai_interview_2026_secret
|
||||
```
|
||||
|
||||
### 3.3 部署命令
|
||||
|
||||
```bash
|
||||
cd /www/wwwroot/ai-interview/deploy
|
||||
|
||||
# 构建并启动
|
||||
docker-compose up -d --build
|
||||
|
||||
# 查看日志
|
||||
docker-compose logs -f
|
||||
|
||||
# 停止服务
|
||||
docker-compose down
|
||||
|
||||
# 重启服务
|
||||
docker-compose restart
|
||||
```
|
||||
|
||||
### 3.4 端口映射
|
||||
|
||||
| 服务 | 容器端口 | 宿主机端口 |
|
||||
|------|----------|------------|
|
||||
| Frontend | 80 | 3000 |
|
||||
| Backend | 8000 | 8000 |
|
||||
|
||||
## 四、Nginx 反向代理配置
|
||||
|
||||
### 4.1 前端 + API 合并 (推荐)
|
||||
|
||||
域名: `interview.test.ai.ireborn.com.cn`
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
listen 443 ssl http2;
|
||||
server_name interview.test.ai.ireborn.com.cn;
|
||||
|
||||
# SSL 证书 (宝塔自动配置)
|
||||
ssl_certificate /www/server/panel/vhost/cert/interview.test.ai.ireborn.com.cn/fullchain.pem;
|
||||
ssl_certificate_key /www/server/panel/vhost/cert/interview.test.ai.ireborn.com.cn/privkey.pem;
|
||||
|
||||
# 前端
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# API 代理 (前端容器内部已处理,此处可选)
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:8000/api/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 120s;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 独立 API 域名 (可选)
|
||||
|
||||
域名: `interview-api.test.ai.ireborn.com.cn`
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
listen 443 ssl http2;
|
||||
server_name interview-api.test.ai.ireborn.com.cn;
|
||||
|
||||
ssl_certificate /www/server/panel/vhost/cert/interview-api.test.ai.ireborn.com.cn/fullchain.pem;
|
||||
ssl_certificate_key /www/server/panel/vhost/cert/interview-api.test.ai.ireborn.com.cn/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 120s;
|
||||
proxy_connect_timeout 120s;
|
||||
|
||||
# CORS
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
|
||||
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 五、更新部署
|
||||
|
||||
```bash
|
||||
cd /www/wwwroot/ai-interview
|
||||
|
||||
# 拉取最新代码
|
||||
git pull origin main
|
||||
|
||||
# 重新构建并部署
|
||||
cd deploy
|
||||
docker-compose down
|
||||
docker-compose up -d --build
|
||||
|
||||
# 查看状态
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
## 六、故障排查
|
||||
|
||||
### 6.1 查看容器日志
|
||||
|
||||
```bash
|
||||
# 前端日志
|
||||
docker logs ai-interview-frontend
|
||||
|
||||
# 后端日志
|
||||
docker logs ai-interview-backend
|
||||
```
|
||||
|
||||
### 6.2 进入容器调试
|
||||
|
||||
```bash
|
||||
# 进入后端容器
|
||||
docker exec -it ai-interview-backend /bin/sh
|
||||
|
||||
# 进入前端容器
|
||||
docker exec -it ai-interview-frontend /bin/sh
|
||||
```
|
||||
|
||||
### 6.3 常见问题
|
||||
|
||||
| 问题 | 解决方案 |
|
||||
|------|----------|
|
||||
| 前端白屏 | 检查 nginx 配置,确保 `try_files` 指向 index.html |
|
||||
| API 404 | 检查 proxy_pass 地址和端口 |
|
||||
| CORS 错误 | 在 nginx 添加 CORS 头 |
|
||||
| 环境变量无效 | 确认 .env 文件存在且格式正确 |
|
||||
Reference in New Issue
Block a user