-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose.yml
145 lines (145 loc) · 3.74 KB
/
compose.yml
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
version: "3.7"
services:
kafka:
image: bitnami/kafka:3.6.1
container_name: kafka
networks:
- kafka_network
ports:
- "9092:9092"
environment:
- KAFKA_CFG_NODE_ID=0
- KAFKA_CFG_PROCESS_ROLES=controller,broker
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
healthcheck:
# ensure topic is created before marked as ready
test: "kafka-topics.sh --list --bootstrap-server localhost:9092 && kafka-topics.sh --create --bootstrap-server localhost:9092 --if-not-exists --topic stock_price_changes"
interval: 5s
timeout: 10s
retries: 30
postgres:
image: postgres:16.1
container_name: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
volumes:
- ./database/create.sql:/docker-entrypoint-initdb.d/create.sql
- ./database/insert.sql:/docker-entrypoint-initdb.d/insert.sql
networks:
- postgres_network
ports:
- "5432:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 5s
timeout: 10s
retries: 30
producer:
build: producer
container_name: producer
environment:
- PRODUCER_SPEED_MS=1000
- PRODUCER_TOPIC=stock_price_changes
- PGHOST=postgres
- PGUSER=postgres
- PGPASSWORD=123456
networks:
- kafka_network
- postgres_network
depends_on:
kafka:
condition: service_healthy
postgres:
condition: service_healthy
consumer-realtime:
build: consumer-realtime
container_name: consumer-realtime
environment:
- CONSUMER_TOPIC=stock_price_changes
- CONSUMER_GROUP_ID=stock_price_realtime
- PGHOST=postgres
- PGUSER=postgres
- PGPASSWORD=123456
networks:
- kafka_network
- postgres_network
depends_on:
kafka:
condition: service_healthy
postgres:
condition: service_healthy
consumer-aggregate:
build: consumer-aggregate
container_name: consumer-aggregate
environment:
- CONSUMER_TOPIC=stock_price_changes
- CONSUMER_GROUP_ID=stock_price_aggregate
- CONSUMER_WINDOW_TIME_MS=60000
- PGHOST=postgres
- PGUSER=postgres
- PGPASSWORD=123456
networks:
- kafka_network
- postgres_network
depends_on:
kafka:
condition: service_healthy
postgres:
condition: service_healthy
api:
build: api
container_name: api
environment:
- API_PG_HOST=postgres
- API_PG_PORT=5432
- API_PG_USER=postgres
- API_PG_PASSWORD=123456
- API_KAFKA_BROKER=kafka:9092
- API_KAFKA_TOPIC=stock_price_changes
- API_PORT=3000
ports:
- "3000:3000"
networks:
- postgres_network
- kafka_network
- reverse_proxy
depends_on:
kafka:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: "wget --no-verbose --tries=1 --spider localhost:3000/stocks || exit 1"
interval: 5s
timeout: 10s
retries: 30
frontend:
build: frontend
container_name: frontend
networks:
- reverse_proxy
depends_on:
api:
condition: service_healthy
reverse-proxy:
build: reverse-proxy
container_name: reverse-proxy
ports:
- "8080:80"
restart: always
networks:
- reverse_proxy
depends_on:
frontend:
condition: service_started
api:
condition: service_healthy
networks:
kafka_network:
postgres_network:
reverse_proxy: