-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
131 lines (124 loc) · 4.02 KB
/
docker-compose.yml
File metadata and controls
131 lines (124 loc) · 4.02 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Multi-container chat platform with Kafka communication.
#
# Architecture:
# gateway - SPA + reverse proxy (port 8080)
# api - Auth + platform CRUD (port 8081)
# conversation - Chat state machine + providers (port 8082)
# kafka - Event bus (KRaft mode, no Zookeeper)
#
# Usage:
# Distributed: docker compose --profile distributed up
# Monolith: go run ./cmd/server -config example/chat-platform/workflow.yaml
services:
# --- Kafka (KRaft mode — no Zookeeper) ---
kafka:
image: apache/kafka:latest
environment:
- KAFKA_NODE_ID=0
- KAFKA_PROCESS_ROLES=broker,controller
- KAFKA_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
- KAFKA_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER
- KAFKA_AUTO_CREATE_TOPICS_ENABLE=true
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
- KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0
- CLUSTER_ID=chat-platform-kafka-cluster-001
ports:
- "9092:9092"
healthcheck:
test: ["CMD-SHELL", "/opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list || exit 1"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
profiles: [distributed]
restart: unless-stopped
# --- Gateway: SPA + reverse proxy ---
gateway:
build:
context: ../..
dockerfile: example/chat-platform/Dockerfile
ports:
- "8080:8080"
command: ["./server", "-config", "config/configs/gateway.yaml", "-mgmt-addr", ":9080"]
depends_on:
api:
condition: service_healthy
conversation:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/healthz"]
interval: 10s
timeout: 5s
retries: 3
profiles: [distributed]
restart: unless-stopped
# --- API service: Auth + platform CRUD ---
api:
build:
context: ../..
dockerfile: example/chat-platform/Dockerfile
environment:
- JWT_SECRET=${JWT_SECRET:?JWT_SECRET must be set}
- ENCRYPTION_KEY=${ENCRYPTION_KEY:?ENCRYPTION_KEY must be set}
command: ["./server", "-config", "config/configs/api.yaml", "-mgmt-addr", ":9081"]
volumes:
- api-data:/app/data
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8081/healthz"]
interval: 10s
timeout: 5s
retries: 3
profiles: [distributed]
restart: unless-stopped
# --- Conversation service: Chat + state machine ---
conversation:
build:
context: ../..
dockerfile: example/chat-platform/Dockerfile
environment:
- JWT_SECRET=${JWT_SECRET:?JWT_SECRET must be set}
- ENCRYPTION_KEY=${ENCRYPTION_KEY:?ENCRYPTION_KEY must be set}
command: ["./server", "-config", "config/configs/conversation.yaml", "-mgmt-addr", ":9082"]
volumes:
- conversation-data:/app/data
depends_on:
kafka:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8082/healthz"]
interval: 10s
timeout: 5s
retries: 3
profiles: [distributed]
restart: unless-stopped
# --- Observability ---
prometheus:
image: prom/prometheus:v2.51.0
ports:
- "9090:9090"
volumes:
- ./observability/prometheus.yml:/etc/prometheus/prometheus.yml
depends_on:
- gateway
profiles: [distributed]
restart: unless-stopped
grafana:
image: grafana/grafana:10.4.0
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
- GF_AUTH_ANONYMOUS_ENABLED=false
volumes:
- ./observability/grafana/provisioning:/etc/grafana/provisioning
- ./observability/grafana/dashboards:/var/lib/grafana/dashboards
depends_on:
- prometheus
profiles: [distributed]
restart: unless-stopped
volumes:
api-data:
conversation-data: