Files
012-kaopeilian/docs/测试环境配置.md
yuliang_guo f52c8fde10
Some checks failed
continuous-integration/drone/push Build is failing
docs: 更新测试环境配置文档 - 新分支结构
2026-01-28 12:01:44 +08:00

218 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 考培练系统 - 环境配置与部署指南
> 最后更新2026-01-28
## 一、环境总览
| 环境 | 分支 | 域名 | dist 目录 | 用途 |
|------|------|------|-----------|------|
| **测试环境** | `test` | https://kpl.ireborn.com.cn | dist-test | 功能开发测试 |
| **预生产** | `staging` | https://aiedu.ireborn.com.cn | dist-staging | 集成测试/预发布 |
| **生产环境** | `main` | 各租户域名 | dist-prod | 正式生产 |
| **超级管理后台** | - | https://admin.kpl.ireborn.com.cn | - | SaaS管理 |
---
## 二、租户列表
| 租户代码 | 名称 | 域名 | 前端端口 | 后端端口 |
|----------|------|------|----------|----------|
| hua | 华尔倍丽 | https://hua.ireborn.com.cn | 3010 | 8010 |
| yy | 杨扬宠物 | https://yy.ireborn.com.cn | 3011 | 8011 |
| hl | 武汉禾丽 | https://hl.ireborn.com.cn | 3012 | 8012 |
| xy | 芯颜定制 | https://xy.ireborn.com.cn | 3013 | 8013 |
| fw | 飞沃 | https://fw.ireborn.com.cn | 3014 | 8014 |
| ex | 恩喜成都总院 | https://ex.ireborn.com.cn | 3015 | 8015 |
| cxw | 崔曦文 | https://cxw.kpl.ireborn.com.cn | 3016 | 8016 |
---
## 三、CI/CD 部署方式
### 3.1 开发1环境 (kpl-dev)
```bash
# 推送到 test 分支自动部署
git push cicd test
```
- **触发条件**`test` 分支 push
- **部署目标**kpl-dev 容器组
- **访问地址**https://kpl.ireborn.com.cn
---
### 3.2 开发2环境 (主站)
```bash
# 推送到 dev2 分支自动部署
git push cicd dev2
```
- **触发条件**`dev2` 分支 push
- **部署目标**kaopeilian 主站容器
- **访问地址**https://aiedu.ireborn.com.cn
---
### 3.3 生产环境 (租户)
```bash
# 推送到 main 分支,通过 commit message 控制部署范围
git push cicd main
```
#### 部署所有租户
```bash
git commit -m "feat: 新功能上线 [all]"
git push cicd main
```
#### 部署单个租户
```bash
git commit -m "fix: 修复问题 [hua]"
git push cicd main
```
#### 部署多个租户
```bash
git commit -m "feat: 功能更新 [cxw,yy,hl]"
git push cicd main
```
#### 默认行为
```bash
# 不带标签默认部署所有租户
git commit -m "feat: 常规更新"
git push cicd main
```
---
## 四、手动部署命令
### 4.1 SSH 登录服务器
```bash
ssh root@120.79.247.16
# 密码: Rxm88808
```
### 4.2 重启单个租户后端
```bash
cd /root/aiedu
docker restart cxw-backend
```
### 4.3 重建单个租户后端
```bash
cd /root/aiedu
docker-compose -f docker-compose.prod-multi.yml up -d --build --no-deps cxw-backend
```
### 4.4 查看日志
```bash
docker logs -f cxw-backend --tail 100
```
### 4.5 重新编译前端(所有租户共享)
```bash
cd /root/aiedu/kaopeilian-frontend
npm run build
```
---
## 五、数据库连接
### 5.1 生产共享 MySQL (prod-mysql)
- **端口**3309
- **用户**root
- **密码**ProdMySQL2025!@#
- **数据库**kaopeilian_hua, kaopeilian_yy, kaopeilian_hl, kaopeilian_xy, kaopeilian_fw, kaopeilian_ex, kaopeilian_cxw
### 5.2 开发测试 MySQL (kpl-mysql-dev)
- **端口**3308
- **用户**root
- **密码**nj861021
- **数据库**kaopeilian
### 5.3 主站 MySQL (kaopeilian-mysql)
- **端口**3307
- **用户**root
- **密码**nj861021
- **数据库**kaopeilian
---
## 六、容器管理
### 当前运行容器统计
| 类型 | 数量 |
|------|------|
| 前端容器 | 11 |
| 后端容器 | 11 |
| Redis | 10 |
| MySQL | 4 |
| Nginx | 1 |
| **总计** | **37** |
### 查看所有容器
```bash
docker ps --format 'table {{.Names}}\t{{.Status}}'
```
---
## 七、测试账户
| 角色 | 用户名 | 密码 |
|------|--------|------|
| 系统管理员 | admin | Admin123! |
| 培训经理 | manager | Admin123! |
| 测试学员 | testuser | Admin123! |
---
## 八、注意事项
1. **前端共享**:所有生产租户共享同一套前端代码,编译一次全部更新
2. **后端独立**:每个租户有独立的后端容器和数据库
3. **域名解析**
- `*.ireborn.com.cn` 解析到 120.79.242.43SCRM服务器
- `*.kpl.ireborn.com.cn` 解析到 120.79.247.16(考培练服务器)
4. **SSL证书**:使用 Let's Encrypt自动续期
---
## 九、Git 仓库配置
```bash
# 查看远程仓库
git remote -v
# origin: GitHub 源代码仓库
# cicd: Gitea CI/CD 触发仓库
# 常规开发
git push origin main
# 触发部署
git push cicd test # 部署开发1
git push cicd dev2 # 部署开发2
git push cicd main # 部署生产
```