template-monorepo/deploy/README.md

1.8 KiB
Raw Blame History

本機依賴Docker Compose

Gateway 啟用 Notification / Member OTP 需要:

服務 用途 預設埠
MongoDB notificationsnotification_dlq collections 27017
Redis 冪等、配額、異步重試佇列、member OTP challenge 6379
MailHog選用 本機 SMTP 測試 1025 / 8025

Mongo 不需要事先手動建 collection應用程式寫入時會自動建立。索引由 init script 或 make mongo-index 建立。

快速開始

# 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,與 Go 的 Index20260520001UP 一致。

常用指令

make deps-up        # docker compose up -d mongo redis
make deps-up-smtp   # 再加上 mailhogprofile smtp
make deps-down      # 停止並移除容器(保留 volume
make deps-down-v    # 停止並刪除 volume會清掉 Mongo 資料)
make deps-logs      # 查看 log
make mongo-index    # 手動建立/補齊索引

連線設定

設定說明:etc/README.md

檔案 用途
etc/gateway.yaml 預設,無需 Docker
etc/gateway.dev.example.yaml 範例(可提交)
etc/gateway.dev.yaml 本機專用(勿提交,見 .gitignore