-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
114 lines (108 loc) · 3.82 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
114 lines (108 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Local backing services for the Hatef Identity Platform (MVP single-node dev).
#
# Provides the three stateful dependencies the Go IdP relies on:
# - PostgreSQL : primary transactional store (users, RBAC, recovery codes,
# mvp_audit_logs) with ACID guarantees.
# - Redis : sessions, DPoP jti replay cache, and OTP rate-limit sliding
# windows (persisted via AOF so windows survive restarts).
# - NATS : async event broadcasting (identity.user.*) and the durable
# audit-log queue (identity.audit.logs) via JetStream.
#
# No secrets are hardcoded (see DoD #3). Values are read from a root `.env`
# file (gitignored) with safe non-secret dev defaults for out-of-the-box local
# runs. Copy `.env.example` to `.env` to override. Ports bind to loopback only
# so the backing services are never exposed on the host's public interface.
#
# Usage:
# docker compose -f docker-compose.dev.yml up -d
# docker compose -f docker-compose.dev.yml down # keep data
# docker compose -f docker-compose.dev.yml down -v # wipe volumes
name: hatef-idp-dev
services:
postgres:
image: postgres:16-alpine
container_name: hatef-idp-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-identity}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-identity_dev_password}
POSTGRES_DB: ${POSTGRES_DB:-identity}
# Fail fast on auth misconfig instead of silently trusting local conns.
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
ports:
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes:
- pg_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-identity} -d ${POSTGRES_DB:-identity}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- hatef-idp-net
redis:
image: redis:7-alpine
container_name: hatef-idp-redis
restart: unless-stopped
# --appendonly yes : durable AOF so OTP sliding-window ZSETs and session
# state survive container restarts (data-architecture §3).
# --requirepass : optional auth; enabled only when REDIS_PASSWORD is set.
command:
- redis-server
- --appendonly
- "yes"
- --requirepass
- "${REDIS_PASSWORD:-}"
ports:
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
# Uses REDISCLI_AUTH (picked up by redis-cli) so the check works whether
# or not a password is configured, without leaking it into the command.
test: ["CMD-SHELL", "REDISCLI_AUTH=\"${REDIS_PASSWORD:-}\" redis-cli ping | grep -q PONG"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
networks:
- hatef-idp-net
nats:
image: nats:2.10-alpine
container_name: hatef-idp-nats
restart: unless-stopped
# -js : enable JetStream (persistence for events + audit queue).
# -sd : JetStream store directory (backed by a named volume).
# -m : HTTP monitoring endpoint (used for the healthcheck /healthz probe).
command:
- "-js"
- "-sd"
- "/data"
- "-m"
- "8222"
ports:
- "127.0.0.1:${NATS_PORT:-4222}:4222" # client connections
- "127.0.0.1:${NATS_MONITOR_PORT:-8222}:8222" # monitoring / healthz
volumes:
- nats_data:/data
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:8222/healthz | grep -q ok"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
networks:
- hatef-idp-net
volumes:
pg_data:
name: hatef-idp-pg-data
redis_data:
name: hatef-idp-redis-data
nats_data:
name: hatef-idp-nats-data
networks:
hatef-idp-net:
name: hatef-idp-net
driver: bridge