fix(build): vite部署问题,部署后有缓存取到旧的chunk文件
This commit is contained in:
1 parent
09deada712
commit
57652ae581
7 files changed
+62
-108
No files matched your search
@@ -55,6 +55,19 @@ location /api/ {
|
||||
}
|
||||
```
|
||||
|
||||
同时为静态与 `index.html` 设置了缓存策略,避免部署后浏览器/网关缓存旧版 `index.html`,引用部署时已删除的旧 hash 产物,导致登录后懒加载 chunk 404(报 `Failed to fetch dynamically imported module`):
|
||||
|
||||
```nginx
|
||||
# Vite 构建产物(带 hash、内容寻址):可长期 immutable 缓存,文件名一变即失效
|
||||
location /assets/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
# index.html 必须始终重新校验,避免引用旧 hash
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
```
|
||||
|
||||
#### 5.2.3 自动化部署脚本 (`scripts/deploy_compose.sh`)
|
||||
当前标准部署入口(Jenkins 与服务器手工均使用此脚本):
|
||||
1. **环境选择**: 参数 `dev` / `test` / `prod`,对应 `.env.dev`、`.env.test`、`.env.prod` 与 `.env.shared`。
|
||||
|
||||
+13
-13
@@ -24,7 +24,7 @@
|
||||
|
||||
### 基础设施 (Infrastructure)
|
||||
- **反向代理**: Nginx (处理 HTTPS, 静态资源, 反向代理)
|
||||
- **进程管理**: Supervisor (守护 Gunicorn 进程)
|
||||
- **进程管理**: Docker Compose 容器化(容器内由 CMD 启动 Gunicorn / Worker)
|
||||
- **数据库**: PostgreSQL (生产环境)
|
||||
- **缓存**: Redis (可选,用于 Session 或 任务队列)
|
||||
- **代码托管**: Gitee (`super` 分支)
|
||||
@@ -55,31 +55,31 @@ hxops/
|
||||
│ └── vite.config.ts # Vite 配置
|
||||
├── scripts/ # 运维与自动化脚本
|
||||
│ ├── deploy_compose.sh # Docker Compose 部署(Jenkins / 服务器)
|
||||
│ ├── nginx.conf # Nginx 生产配置
|
||||
│ └── supervisord.conf # Supervisor 配置
|
||||
└── docs/ # 项目文档
|
||||
```
|
||||
|
||||
## 4. 🏗️ 部署架构 (Deployment Architecture)
|
||||
|
||||
### 4.1 生产环境架构
|
||||
为了满足高并发(500+ QPS)及稳定性要求,架构设计如下:
|
||||
采用 Docker Compose 容器化部署,组件职责分离:
|
||||
|
||||
1. **Nginx (接入层)**:
|
||||
- 监听 80/443 端口。
|
||||
1. **前置 Nginx / nginx-gateway (接入层)**:
|
||||
- 对外生产入口(正式域名 `ai.well-trust.com:8881`),反向代理前端容器。
|
||||
- **关键配置**: `proxy_buffering off;` (必须关闭缓冲以支持 SSE 流式响应)。
|
||||
- 提供前端静态资源 (`/dist`) 服务,开启 Gzip 压缩。
|
||||
|
||||
2. **Supervisor (进程管理)**:
|
||||
- 守护 `hxops-backend` 进程,负责自动重启和日志管理。
|
||||
2. **hxops-frontend (Nginx 容器)**:
|
||||
- 多阶段构建:Node 生成 `dist`,Nginx 托管静态资源并反代 `/api/` 到后端容器。
|
||||
- 容器内监听 `80`,宿主机映射 `8890`;配置见 `frontend/nginx.conf`。
|
||||
|
||||
3. **Gunicorn + Gevent (应用层)**:
|
||||
- 运行 Flask 应用。
|
||||
3. **hxops-backend (应用层)**:
|
||||
- Flask + Gunicorn + Gevent,容器内监听 `5000`(经前端容器 `hxops-backend:5000` 反代)。
|
||||
- **Worker**: `gevent` (异步模式)。
|
||||
- **并发**: `workers = CPU * 2 + 1`, `worker_connections = 1000+`。
|
||||
- 监听 `127.0.0.1:5052`。
|
||||
|
||||
4. **PostgreSQL (数据层)**:
|
||||
4. **后台 Worker**:
|
||||
- `hxops-kb-worker` / `hxops-schedule-worker` / `hxops-shipping-worker`,与 backend 共用镜像,分担知识库、排程与发货通知任务。
|
||||
|
||||
5. **PostgreSQL (数据层)**:
|
||||
- 存储用户、应用配置及审计日志。
|
||||
|
||||
### 4.2 CI/CD 工作流
|
||||
|
||||
Reference in new issue
Block a user