2026-02-27 18:21:22 +08:00
|
|
|
# uniservice-mobile.hnxinyouhe.com 线上部署说明
|
|
|
|
|
|
|
|
|
|
## 线上环境信息
|
|
|
|
|
|
|
|
|
|
| 项目 | 值 |
|
|
|
|
|
|------|-----|
|
|
|
|
|
| **域名** | uniservice-mobile.hnxinyouhe.com |
|
2026-02-27 18:50:44 +08:00
|
|
|
| **站点目录** | /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index |
|
|
|
|
|
| **项目目录** | /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server |
|
2026-02-27 18:39:20 +08:00
|
|
|
| **后端容器** | x-server-backend-prod (端口 8787) |
|
2026-02-27 18:21:22 +08:00
|
|
|
| **MySQL 容器** | 1Panel-mysql-XyxS |
|
|
|
|
|
| **Redis 容器** | 1Panel-redis-pxdb |
|
|
|
|
|
| **Docker 网络** | 1panel-network |
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
## 部署架构
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
| 组件 | 部署方式 |
|
|
|
|
|
|------|---------|
|
|
|
|
|
| **前端** | 本地构建 → 上传静态文件 |
|
|
|
|
|
| **后端** | Git 拉取 → Docker 重启 |
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
---
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
## 目录结构
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
```
|
|
|
|
|
/opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/
|
|
|
|
|
├── index.html # 前端入口
|
|
|
|
|
├── assets/ # 前端静态资源
|
|
|
|
|
└── server/ # 整个项目(Git 仓库)
|
|
|
|
|
├── backend/ # 后端代码
|
|
|
|
|
│ ├── app/
|
|
|
|
|
│ ├── config/
|
|
|
|
|
│ └── ...
|
|
|
|
|
├── deploy/ # 部署配置
|
|
|
|
|
│ ├── docker-compose.prod.yml
|
|
|
|
|
│ ├── .env.production
|
|
|
|
|
│ └── deploy.sh
|
|
|
|
|
├── frontend/ # 前端源码(不使用)
|
|
|
|
|
├── docs/ # 文档
|
|
|
|
|
└── logs/ # 日志
|
|
|
|
|
└── backend/
|
2026-02-27 18:21:22 +08:00
|
|
|
```
|
|
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
---
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
## 快速部署
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 前端部署(本地)
|
2026-02-27 18:21:22 +08:00
|
|
|
|
|
|
|
|
```bash
|
2026-02-27 18:39:20 +08:00
|
|
|
# 本地构建
|
2026-02-27 18:21:22 +08:00
|
|
|
cd /www/x-server-mobile/frontend
|
2026-02-27 18:24:42 +08:00
|
|
|
npm run build
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
# 上传静态文件
|
|
|
|
|
rsync -avz --delete \
|
|
|
|
|
frontend/dist/ \
|
2026-02-27 18:50:44 +08:00
|
|
|
root@45.153.130.80:/opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/
|
2026-02-27 18:24:42 +08:00
|
|
|
```
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 后端部署(服务器)
|
2026-02-27 18:21:22 +08:00
|
|
|
|
|
|
|
|
```bash
|
2026-02-27 18:39:20 +08:00
|
|
|
# 登录服务器
|
2026-02-27 18:50:44 +08:00
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
cd /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server
|
2026-02-27 18:39:20 +08:00
|
|
|
|
|
|
|
|
# 拉取代码
|
2026-02-27 18:50:44 +08:00
|
|
|
git pull origin master
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
# 重启容器
|
2026-02-27 18:50:44 +08:00
|
|
|
docker-compose -f deploy/docker-compose.prod.yml down
|
|
|
|
|
docker-compose -f deploy/docker-compose.prod.yml up -d
|
2026-02-27 18:39:20 +08:00
|
|
|
```
|
|
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
或使用部署脚本:
|
2026-02-27 18:39:20 +08:00
|
|
|
```bash
|
2026-02-27 18:50:44 +08:00
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
cd /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server
|
|
|
|
|
./deploy/deploy.sh
|
2026-02-27 18:24:42 +08:00
|
|
|
```
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
---
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
## 首次部署
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 1. 克隆后端代码
|
2026-02-27 18:24:42 +08:00
|
|
|
|
|
|
|
|
```bash
|
2026-02-27 18:50:44 +08:00
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
cd /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index
|
2026-02-27 18:39:20 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
# 克隆 master 分支
|
|
|
|
|
git clone <your-git-repository-url> server
|
|
|
|
|
cd server
|
|
|
|
|
git checkout master
|
|
|
|
|
```
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 2. 上传 Dockerfile
|
2026-02-27 18:39:20 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
```bash
|
|
|
|
|
# 本地执行
|
|
|
|
|
scp backend/Dockerfile.prod root@45.153.130.80:/opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server/backend/
|
2026-02-27 18:39:20 +08:00
|
|
|
```
|
|
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 3. 配置环境变量
|
2026-02-27 18:39:20 +08:00
|
|
|
|
|
|
|
|
```bash
|
2026-02-27 18:50:44 +08:00
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
vi /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server/deploy/.env.production
|
2026-02-27 18:39:20 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
填写飞书配置:
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
```env
|
|
|
|
|
FEISHU_APP_ID=cli_axxxxxxxxxxxx
|
|
|
|
|
FEISHU_APP_SECRET=xxxxxxxxxxxxxxxxxxxx
|
|
|
|
|
FEISHU_ENCRYPT_KEY=xxxxxxxxxxxxxxxxxxxx
|
|
|
|
|
FEISHU_VERIFICATION_TOKEN=xxxxxxxxxxxxxxxxxxxx
|
|
|
|
|
```
|
2026-02-27 18:24:42 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 4. 创建日志目录
|
2026-02-27 18:39:20 +08:00
|
|
|
|
|
|
|
|
```bash
|
2026-02-27 18:50:44 +08:00
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
mkdir -p /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server/logs/backend
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 5. 上传部署脚本
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 本地执行
|
|
|
|
|
scp deploy/server-deploy.sh root@45.153.130.80:/opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server/deploy/deploy.sh
|
|
|
|
|
|
|
|
|
|
# 赋予执行权限
|
|
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
chmod +x /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server/deploy/deploy.sh
|
2026-02-27 18:21:22 +08:00
|
|
|
```
|
|
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 6. 启动后端容器
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
```bash
|
|
|
|
|
ssh root@45.153.130.80
|
|
|
|
|
cd /opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/server
|
|
|
|
|
docker-compose -f deploy/docker-compose.prod.yml up -d
|
|
|
|
|
docker ps | grep x-server
|
|
|
|
|
```
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
### 7. 上传前端
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
```bash
|
|
|
|
|
cd /www/x-server-mobile/frontend
|
|
|
|
|
npm run build
|
|
|
|
|
rsync -avz --delete \
|
|
|
|
|
frontend/dist/ \
|
2026-02-27 18:50:44 +08:00
|
|
|
root@45.153.130.80:/opt/1panel/www/sites/uniservice-mobile.hnxinyouhe.com/index/
|
2026-02-27 18:39:20 +08:00
|
|
|
```
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
---
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
## 1Panel Nginx 配置
|
2026-02-27 18:21:22 +08:00
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
在 1Panel 面板(网站设置 → 配置文件)添加反向代理:
|
|
|
|
|
|
|
|
|
|
```nginx
|
|
|
|
|
# 后端 API
|
2026-02-27 18:21:22 +08:00
|
|
|
location /api/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:8787;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
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_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
# 飞书登录回调
|
2026-02-27 18:21:22 +08:00
|
|
|
location /login {
|
|
|
|
|
proxy_pass http://127.0.0.1:8787;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
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_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /login/callback {
|
|
|
|
|
proxy_pass http://127.0.0.1:8787;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
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_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /login/qrcode {
|
|
|
|
|
proxy_pass http://127.0.0.1:8787;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
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_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 飞书卡片回调
|
|
|
|
|
location /feishu/card/callback {
|
|
|
|
|
proxy_pass http://127.0.0.1:8787;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
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_set_header Host $host;
|
|
|
|
|
}
|
2026-02-27 18:24:42 +08:00
|
|
|
```
|
|
|
|
|
|
2026-02-27 18:21:22 +08:00
|
|
|
---
|
|
|
|
|
|
2026-02-27 18:24:42 +08:00
|
|
|
## 部署验证
|
|
|
|
|
|
2026-02-27 18:21:22 +08:00
|
|
|
```bash
|
2026-02-27 18:39:20 +08:00
|
|
|
# 检查前端
|
2026-02-27 18:21:22 +08:00
|
|
|
curl -I https://uniservice-mobile.hnxinyouhe.com
|
|
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
# 检查后端容器
|
2026-02-27 18:50:44 +08:00
|
|
|
ssh root@45.153.130.80
|
2026-02-27 18:21:22 +08:00
|
|
|
docker ps | grep x-server
|
|
|
|
|
docker logs -f x-server-backend-prod
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 常见问题
|
|
|
|
|
|
2026-02-27 18:39:20 +08:00
|
|
|
| 问题 | 解决方案 |
|
|
|
|
|
|------|---------|
|
|
|
|
|
| API 404 | 检查 Nginx 反向代理配置 |
|
|
|
|
|
| 容器启动失败 | 检查数据库/Redis 容器状态,查看日志 |
|
2026-02-27 18:50:44 +08:00
|
|
|
| 飞书登录失败 | 检查 `/login/*` 反向代理配置 |
|
2026-02-27 18:39:20 +08:00
|
|
|
| 静态资源 404 | 确认前端上传到正确目录 |
|
2026-02-27 18:24:42 +08:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 文件清单
|
|
|
|
|
|
2026-02-27 18:50:44 +08:00
|
|
|
需要上传到服务器的文件:
|
|
|
|
|
|
|
|
|
|
| 文件 | 目标位置 |
|
|
|
|
|
|------|---------|
|
|
|
|
|
| `backend/Dockerfile.prod` | `server/backend/` |
|
|
|
|
|
| `deploy/docker-compose.prod.yml` | `server/deploy/` |
|
|
|
|
|
| `deploy/.env.production` | `server/deploy/` |
|
|
|
|
|
| `deploy/server-deploy.sh` | `server/deploy/deploy.sh` |
|