2026-05-20 07:01:08 +00:00
|
|
|
|
# 本機依賴(Docker Compose)
|
|
|
|
|
|
|
|
|
|
|
|
Gateway 啟用 **Notification** / **Member OTP** 需要:
|
|
|
|
|
|
|
|
|
|
|
|
| 服務 | 用途 | 預設埠 |
|
|
|
|
|
|
|------|------|--------|
|
|
|
|
|
|
| **MongoDB** | `notifications`、`notification_dlq` collections | 27017 |
|
|
|
|
|
|
| **Redis** | 冪等、配額、異步重試佇列、member OTP challenge | 6379 |
|
|
|
|
|
|
| MailHog(選用) | 本機 SMTP 測試 | 1025 / 8025 |
|
2026-05-27 09:28:13 +00:00
|
|
|
|
| OpenLDAP(`make k6-up`) | ZITADEL LDAP IdP 本機目錄 | 389 |
|
|
|
|
|
|
| ZITADEL(`make k6-up`) | OIDC / Social / LDAP 登入 | 8080 |
|
2026-05-20 07:01:08 +00:00
|
|
|
|
|
|
|
|
|
|
Mongo **不需要**事先手動建 collection;應用程式寫入時會自動建立。索引由 init script 或 `make mongo-index` 建立。
|
|
|
|
|
|
|
|
|
|
|
|
## 快速開始
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# 1. 啟動 Mongo + Redis
|
|
|
|
|
|
make deps-up
|
|
|
|
|
|
|
|
|
|
|
|
# 2.(選用)含 MailHog
|
|
|
|
|
|
make deps-up-smtp
|
|
|
|
|
|
|
|
|
|
|
|
# 3. 確認索引(首次 docker volume 通常已由 init 建立;可再跑一次保險)
|
|
|
|
|
|
make mongo-index
|
|
|
|
|
|
|
|
|
|
|
|
# 4. 啟動 Gateway(使用 etc/gateway.dev.yaml)
|
|
|
|
|
|
make run-dev
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Mongo collections
|
|
|
|
|
|
|
|
|
|
|
|
| Collection | 模組 | 說明 |
|
|
|
|
|
|
|------------|------|------|
|
|
|
|
|
|
| `notifications` | notification | 發送紀錄、冪等 |
|
|
|
|
|
|
| `notification_dlq` | notification | 超過 MaxRetry 的死信 |
|
|
|
|
|
|
|
|
|
|
|
|
索引定義見 [`deploy/mongo/init/01-gateway-indexes.js`](mongo/init/01-gateway-indexes.js),與 Go 的 `Index20260520001UP` 一致。
|
|
|
|
|
|
|
|
|
|
|
|
## 常用指令
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
make deps-up # docker compose up -d mongo redis
|
|
|
|
|
|
make deps-up-smtp # 再加上 mailhog(profile smtp)
|
2026-05-27 09:28:13 +00:00
|
|
|
|
make k6-up # 全棧含 OpenLDAP + ZITADEL(見 deploy/zitadel、deploy/openldap README)
|
|
|
|
|
|
make ldap-test # 確認 LDAP 測試帳號 alice/bob
|
2026-05-20 07:01:08 +00:00
|
|
|
|
make deps-down # 停止並移除容器(保留 volume)
|
|
|
|
|
|
make deps-down-v # 停止並刪除 volume(會清掉 Mongo 資料)
|
|
|
|
|
|
make deps-logs # 查看 log
|
|
|
|
|
|
make mongo-index # 手動建立/補齊索引
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-05-27 09:28:13 +00:00
|
|
|
|
LDAP 本機測試:[deploy/openldap/README.md](openldap/README.md)
|
|
|
|
|
|
|
2026-05-20 07:01:08 +00:00
|
|
|
|
## 連線設定
|
|
|
|
|
|
|
|
|
|
|
|
設定說明:[`etc/README.md`](../etc/README.md)
|
|
|
|
|
|
|
|
|
|
|
|
| 檔案 | 用途 |
|
|
|
|
|
|
|------|------|
|
|
|
|
|
|
| [`etc/gateway.yaml`](../etc/gateway.yaml) | 預設,無需 Docker |
|
2026-05-20 07:14:44 +00:00
|
|
|
|
| [`etc/gateway.dev.example.yaml`](../etc/gateway.dev.example.yaml) | 範例(可提交) |
|
|
|
|
|
|
| `etc/gateway.dev.yaml` | 本機專用(**勿提交**,見 `.gitignore`) |
|