chore: harden build and deployment workflow

This commit is contained in:
237899745
2026-07-27 13:07:14 +08:00
parent 6692736e88
commit f5377e51bb
10 changed files with 408 additions and 71 deletions

View File

@@ -6,7 +6,7 @@
![Version](https://img.shields.io/badge/version-3.1.0-blue.svg)
![License](https://img.shields.io/badge/license-Personal%20Use-green.svg)
![Node](https://img.shields.io/badge/node-20.x-brightgreen.svg)
![Node](https://img.shields.io/badge/node-20.19%2B-brightgreen.svg)
![Vue](https://img.shields.io/badge/vue-3.x-42b883.svg)
</div>
@@ -72,7 +72,7 @@
### 环境要求
- **操作系统**: Linux (Ubuntu 18.04+ / Debian 10+ / CentOS 7+)
- **Node.js**: 20.x LTS(支持 20-24推荐与 `.nvmrc` 保持一致)
- **Node.js**: 20.19+(支持 20.19-24推荐与 `.nvmrc` 保持一致)
- **内存**: 最低 1GB RAM推荐 2GB+
- **磁盘空间**: 至少 2GB 可用空间
- **后端实例数**: 当前限流与用量缓存为进程内状态PM2 必须保持单实例 `fork` 模式
@@ -234,13 +234,16 @@ vue-driven-cloud-storage/
│ ├── data/ # 数据库目录
│ └── storage/ # 本地存储目录
├── frontend/ # 前端代码
├── frontend/ # Vite 多页面 Web 前端
│ ├── index.html # 登录注册页面
│ ├── app.html # 主应用页面
│ ├── share.html # 分享页面
│ ├── verify.html # 邮箱验证页面
│ ├── reset-password.html # 密码重置页面
── libs/ # 第三方库 (Vue.js, Axios, FontAwesome)
── package.json # Vue/Axios/Vite 依赖
│ ├── vite.config.js # 多页面生产构建
│ ├── dist/ # 构建产物(不入库)
│ └── libs/ # 分享页兼容静态资源与 Font Awesome
├── nginx/ # Nginx 配置
│ ├── nginx.conf # 反向代理配置
@@ -272,6 +275,7 @@ vue-driven-cloud-storage/
### 前端技术
- **Vue.js 3** - 渐进式 JavaScript 框架
- **Axios** - HTTP 请求库
- **Vite 8** - 多页面构建、依赖打包与哈希缓存
- **Font Awesome** - 图标库
- **原生 CSS** - 现代化界面设计
@@ -310,7 +314,7 @@ vue-driven-cloud-storage/
```bash
# Systemd 部署
sudo systemctl status vue-cloud-storage
sudo systemctl status wanwanyun
# Docker 部署
docker-compose ps
@@ -320,7 +324,7 @@ docker-compose ps
```bash
# Systemd 部署
sudo journalctl -u vue-cloud-storage -f
sudo journalctl -u wanwanyun -f
# Docker 部署
docker-compose logs -f backend
@@ -330,7 +334,7 @@ docker-compose logs -f backend
```bash
# Systemd 部署
sudo systemctl restart vue-cloud-storage
sudo systemctl restart wanwanyun
# Docker 部署
docker-compose restart
@@ -340,23 +344,26 @@ docker-compose restart
```bash
# 备份数据库
sudo cp /var/www/vue-driven-cloud-storage/backend/data/database.db \
sudo cp /var/www/wanwanyun/backend/data/database.db \
/backup/database.db.$(date +%Y%m%d)
# 备份上传文件(本地存储模式)
sudo tar -czf /backup/uploads-$(date +%Y%m%d).tar.gz \
/var/www/vue-driven-cloud-storage/backend/storage/
/var/www/wanwanyun/backend/storage/
```
### 更新系统
```bash
cd /var/www/vue-driven-cloud-storage
cd /var/www/wanwanyun
git pull
cd backend && npm install
sudo systemctl restart vue-cloud-storage
cd backend && npm ci --omit=dev
cd ../frontend && npm ci --include=dev && npm run build
sudo systemctl restart wanwanyun
```
`install.sh --update` 会在替换线上文件前构建前端,并保留 `frontend/downloads/` 中由管理端发布的桌面安装包。完整工程约束见 [CONTRIBUTING.md](./CONTRIBUTING.md)。
## 📊 性能优化建议
### 生产环境配置
@@ -401,7 +408,7 @@ A: 当前默认限制 10GB可在系统设置和 Nginx 配置中同步调整
### 故障排查
**Q: 无法访问系统**
1. 检查服务是否启动:`sudo systemctl status vue-cloud-storage`
1. 检查服务是否启动:`sudo systemctl status wanwanyun`
2. 检查防火墙是否开放端口
3. 查看 Nginx 日志:`sudo tail -f /var/log/nginx/error.log`
@@ -484,11 +491,14 @@ A: 当前默认限制 10GB可在系统设置和 Nginx 配置中同步调整
git clone https://git.workyai.cn/237899745/vue-driven-cloud-storage.git
cd vue-driven-cloud-storage
# 安装依赖
cd backend && npm install
# 安装并测试后端
cd backend && npm ci && npm test
# 启动开发服务器
node server.js
# 终端一:启动后端
npm run dev
# 终端二:启动 Vite项目根目录执行
cd ../frontend && npm ci && npm run dev
```
### 提交规范