-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
182 lines (170 loc) · 4.11 KB
/
docker-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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
version: "3.9"
services:
producer:
image: producer
container_name: producer
build:
context: .
dockerfile: Dockerfile.producer
command: ["/bin/bash", "-c", "read && python src/main.py"]
stdin_open: true
tty: true
volumes:
- ./producer/src:/app/src
depends_on:
- kafka-init
restart: always
networks:
- backend
consumer:
image: consumer
container_name: consumer
build:
context: .
dockerfile: Dockerfile.consumer
command: ./scripts/run_single_worker.sh
volumes:
- ./consumer/src:/app/src
ports:
- "8000:8000"
depends_on:
- kafka-init
- postgres-db
restart: always
networks:
- backend
postgres-db:
container_name: postgres-db
image: postgres:latest
env_file: ./.env
ports:
- "5433:5432"
volumes:
- data:/var/lib/postgresql/data
restart: always
networks:
- backend
adminer:
container_name: adminer
image: adminer:latest
ports:
- 8081:8080
restart: always
networks:
- backend
zookeeper:
image: confluentinc/cp-zookeeper:latest
container_name: zookeeper
ports:
- 22181:2181
restart: always
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- backend
kafka1:
image: confluentinc/cp-kafka:latest
container_name: kafka1
depends_on:
- zookeeper
ports:
- 29091:9092
restart: always
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29091
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
networks:
- backend
healthcheck:
test: nc -z kafka1 29091 || exit 1
start_period: 15s
interval: 5s
timeout: 10s
retries: 10
kafka2:
image: confluentinc/cp-kafka:latest
container_name: kafka2
depends_on:
- zookeeper
ports:
- 29092:9092
restart: always
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
networks:
- backend
healthcheck:
test: nc -z kafka2 29092 || exit 1
start_period: 15s
interval: 5s
timeout: 10s
retries: 10
kafka3:
image: confluentinc/cp-kafka:latest
container_name: kafka3
depends_on:
- zookeeper
ports:
- 29093:9092
restart: always
environment:
KAFKA_BROKER_ID: 3
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka3:29093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
networks:
- backend
healthcheck:
test: nc -z kafka3 29093 || exit 1
start_period: 15s
interval: 5s
timeout: 10s
retries: 10
kafka-ui:
image: provectuslabs/kafka-ui
container_name: kafka-ui
ports:
- 8090:8080
restart: always
environment:
- KAFKA_CLUSTERS_0_NAME=local
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka1:29091,kafka2:29092,kafka3:29093 # Update with broker hostnames and ports
- KAFKA_CLUSTERS_0_ZOOKEEPER=zookeeper:2181
networks:
- backend
kafka-init:
image: confluentinc/cp-kafka:latest
container_name: kafka-init
networks:
- backend
command: ["/bin/bash", "-c", "/create_topics.sh && tail -f /dev/null"]
env_file: ./.env
depends_on:
kafka1:
condition: service_healthy
kafka2:
condition: service_healthy
kafka3:
condition: service_healthy
volumes:
- type: bind
source: ./create_topics.sh
target: /create_topics.sh
init: true
volumes:
data:
networks:
backend:
driver: bridge