thread-master/deploy/README.md

62 lines
1.9 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.

# 巡樓部署Docker 一鍵啟動)
整套系統用單一 `docker compose` 拉起,對外只開前端 `:80`
```
瀏覽器 → web(nginx :80)
├─ 前端靜態檔vite build
└─ /api 反代 → gateway:8890
gateway / workerGo─┐
node-workerplaywright┤→ Mongo / Redis同網路不對外
```
| 容器 | 角色 |
|------|------|
| `mongo` / `redis` | 資料層(只綁 `127.0.0.1`volume 持久化) |
| `init` | run-once建索引 / 權限 / 第一個 admin冪等跑完即退 |
| `gateway` | API + scheduler + reaper:8890僅內網 |
| `worker` | Go job worker |
| `node-worker` | playwright style-8d |
| `web` | nginxserve 前端 + 反代 `/api` |
## 一鍵啟動
```bash
cp deploy/.env.example deploy/.env # 填密碼與 secret
make up # = docker compose up -d --build
```
啟動順序由 `depends_on` + healthcheck 保證Mongo/Redis 健康 → `init` 跑完 → `gateway`/`worker` 起來 → `gateway` 健康 → `node-worker`/`web` 起來。
## 常用指令
```bash
make ps # 狀態
make logs # 全部日誌
make logs-gateway # 只看 gateway
make down # 停(保留資料)
make down-clean # 停並清空 Mongo/Redis volume
make rebuild # 無快取重建並重啟
make init # 重跑一次 DB 初始化
```
## 健康檢查
```bash
curl http://localhost/api/v1/health
```
## 產生 secret
```bash
openssl rand -base64 48 # JWT access / refresh / worker secret
openssl rand -base64 32 # HAIXUN_SECRETS_KEY機敏資料落地加密
```
## 注意事項
- `deploy/.env` 內含 secret不要 commit。
- `MONGO_ROOT_PASSWORD` 建議只用英數字;含 `@ : / $` 等字元時compose 內的 `HAIXUN_MONGO_URI` 需自行 URL-encode。
- 全系統時間 UTC+0容器 `TZ=UTC`)。
- 本機開發(不全容器化)見根目錄 `make dev`