template-monorepo/deploy/docker-compose.yml

101 lines
2.8 KiB
YAML
Raw Normal View History

2026-05-26 06:05:33 +00:00
# 本機開發 / k6 測試依賴MongoDB、Redis、MailHog、Postgres、ZITADEL
#
# 啟動:
# make deps-up → mongo + redis最小吃 etc/gateway.dev.yaml
# make deps-up-smtp → + mailhogprofile smtp
# make k6-up → mongo + redis + mailhog + postgres + zitadel吃 etc/gateway.k6.yaml
#
# ZITADEL admin PAT 會寫到 deploy/zitadel/machinekey/zitadel-admin-sa.token
services:
mongo:
image: mongo:7
container_name: gateway-mongo
restart: unless-stopped
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: gateway
volumes:
- mongo_data:/data/db
- ./mongo/init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
redis:
image: redis:7-alpine
container_name: gateway-redis
restart: unless-stopped
ports:
- "6379:6379"
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
mailhog:
profiles: ["smtp", "k6"]
image: mailhog/mailhog:v1.0.1
container_name: gateway-mailhog
restart: unless-stopped
ports:
- "1025:1025" # SMTP
- "8025:8025" # Web UI / HTTP API
# ===== ZITADEL stackprofile k6=====
postgres:
profiles: ["k6"]
image: postgres:17-alpine
container_name: gateway-postgres
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: zitadel
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "zitadel"]
interval: 5s
timeout: 3s
retries: 20
zitadel:
profiles: ["k6"]
image: ghcr.io/zitadel/zitadel:v2.65.0
container_name: gateway-zitadel
restart: unless-stopped
command: ["start-from-init", "--masterkey", "MasterkeyNeedsToHave32Characters", "--tlsMode", "disabled", "--config", "/etc/zitadel/zitadel.yaml", "--steps", "/etc/zitadel/steps.yaml"]
depends_on:
postgres:
condition: service_healthy
ports:
- "8080:8080"
volumes:
- ./zitadel/zitadel.yaml:/etc/zitadel/zitadel.yaml:ro
- ./zitadel/steps.yaml:/etc/zitadel/steps.yaml:ro
- ./zitadel/machinekey:/machinekey
healthcheck:
# zitadel image lacks wget/curl; use /proc/net/tcp to verify the port
# is in LISTEN state (10 = LISTEN). Cheap, no binary deps.
test: ["CMD-SHELL", "grep -q ':1F90 .* 0A' /proc/net/tcp || exit 1"]
interval: 5s
timeout: 3s
retries: 60
start_period: 60s
volumes:
mongo_data:
redis_data:
postgres_data: