|
|
||
|---|---|---|
| .. | ||
| .env.dev | ||
| .env.example | ||
| Dockerfile.backend | ||
| Dockerfile.node-worker | ||
| Dockerfile.web | ||
| README.md | ||
| docker-compose.dev.yml | ||
| docker-compose.yml | ||
| nginx.conf | ||
README.md
巡樓部署(Docker 一鍵啟動)
整套系統用單一 docker compose 拉起,對外只開前端 :80。
瀏覽器 → web(nginx :80)
├─ 前端靜態檔(vite build)
└─ /api 反代 → gateway:8890
gateway / worker(Go)─┐
node-worker(playwright)┤→ 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 |
nginx,serve 前端 + 反代 /api |
一鍵啟動
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 起來。
常用指令
make ps # 狀態
make logs # 全部日誌
make logs-gateway # 只看 gateway
make down # 停(保留資料)
make down-clean # 停並清空 Mongo/Redis volume
make rebuild # 無快取重建並重啟
make init # 重跑一次 DB 初始化
健康檢查
curl http://localhost/api/v1/health
產生 secret
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。