Add development environment setup and deployment guides

This commit is contained in:
porsche5130
2026-03-04 01:19:46 +08:00
parent b3c8c28672
commit 0dd8ae21e9
6 changed files with 453 additions and 0 deletions

92
QUICK_START.md Normal file
View File

@@ -0,0 +1,92 @@
# WebMail Gateway 快速開發指南
## 開發環境設定 (最簡單方式)
### 第一步:停止正式環境
```bash
ssh porsche@10.1.0.254 'cd /home/porsche/services/webmail-gateway && docker compose down'
```
### 第二步:在開發機啟動服務
```batch
cd D:\_Develop\porscheworld_develop\webmail-gateway
START_DEVELOPMENT.bat
```
服務會在 `http://10.1.0.245:8100` 啟動
### 第三步:測試訪問
**方式 A: 直接訪問開發機 (推薦)**
- ✅ http://10.1.0.245:8100/vmis-admin
- ✅ http://10.1.0.245:8100/porsche1
**方式 B: 透過 SSH 隧道**
```bash
# 在本機執行
ssh -L 8100:10.1.0.245:8100 porsche@10.1.0.254
# 然後訪問
# http://localhost:8100/vmis-admin
```
**方式 C: 修改 hosts 檔案 (如果需要 HTTPS)**
```
# Windows: C:\Windows\System32\drivers\etc\hosts
10.1.0.245 webmail.lab.taipei
```
然後訪問: http://webmail.lab.taipei:8100/vmis-admin
---
## 開發完成後:部署到正式環境
### 快速部署
```bash
# 1. 上傳修改的檔案
scp app.py porsche@10.1.0.254:/home/porsche/services/webmail-gateway/
# 2. 重啟正式環境
ssh porsche@10.1.0.254 'cd /home/porsche/services/webmail-gateway && docker compose down && docker compose build && docker compose up -d'
```
### 透過 Git 部署 (建立 Gitea 倉庫後)
```bash
# 1. 提交變更
git add .
git commit -m "Feature: 完整 UI 功能"
git push gitea main
# 2. 伺服器拉取
ssh porsche@10.1.0.254
cd /home/porsche/services/webmail-gateway
git pull
docker compose down && docker compose build && docker compose up -d
```
---
## 重要注意事項
⚠️ **Keycloak Redirect URI**
開發時如果使用不同的 URL需要更新 Keycloak client 的 Redirect URI
```
正式環境: https://webmail.lab.taipei/{tenant_code}/callback
開發環境: http://10.1.0.245:8100/{tenant_code}/callback
```
可以同時設定兩個 URI這樣開發和正式環境都能用。
⚠️ **Redis 和 Database**
開發環境會直接連接正式環境的 Redis (10.1.0.20) 和 PostgreSQL (10.1.0.20),請小心操作。
⚠️ **Session 衝突**
如果同時有人在使用正式環境Session 可能會衝突。建議開發時使用測試帳號。