1.5 KiB
1.5 KiB
部署指南
方式一:Docker 部署(推荐)
1. 构建镜像
docker build -t ai-video-assistant-web ./web
2. 运行容器
docker run -d \
--name ai-assistant-web \
-p 3000:80 \
ai-video-assistant-web
3. 使用 Docker Compose
version: '3.8'
services:
web:
build: ./web
ports:
- "3000:80"
environment:
- VITE_API_URL=http://api:8080
运行:
docker-compose up -d
方式二:Nginx 部署
1. 构建前端
cd web
npm run build
2. 配置 Nginx
server {
listen 80;
server_name your-domain.com;
root /var/www/ai-assistant/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
3. 启动 Nginx
sudo nginx -t
sudo systemctl reload nginx
环境变量配置
| 变量 | 说明 | 默认值 |
|---|---|---|
| VITE_API_URL | 后端 API 地址 | http://localhost:8080 |
| VITE_GEMINI_API_KEY | Gemini API Key | - |
验证部署
- 访问 http://your-domain.com
- 检查页面是否正常加载
- 验证各功能模块是否可用
故障排查
| 问题 | 解决方案 |
|---|---|
| 页面空白 | 检查浏览器控制台错误 |
| API 请求失败 | 确认 VITE_API_URL 配置正确 |
| 静态资源 404 | 检查 nginx try_files 配置 |