-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
269 lines (256 loc) · 8.36 KB
/
docker-compose.yml
File metadata and controls
269 lines (256 loc) · 8.36 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
services:
# Infrastructure Services
zookeeper:
image: confluentinc/cp-zookeeper:7.4.0
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:7.4.0
hostname: kafka
container_name: kafka
depends_on:
- zookeeper
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_JMX_PORT: 9101
KAFKA_JMX_HOSTNAME: localhost
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: kafka-ui
depends_on:
- kafka
ports:
- "8085:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:29092
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
# Kafka Connect with Debezium
kafka-connect:
image: debezium/connect:2.4
hostname: kafka-connect
container_name: kafka-connect
depends_on:
- zookeeper
- kafka
- postgres
ports:
- "8086:8083"
environment:
BOOTSTRAP_SERVERS: kafka:29092
GROUP_ID: kafka-connect-cluster
CONFIG_STORAGE_TOPIC: docker-connect-configs
OFFSET_STORAGE_TOPIC: docker-connect-offsets
STATUS_STORAGE_TOPIC: docker-connect-status
# Replication factors for a single broker setup
CONFIG_STORAGE_REPLICATION_FACTOR: 1
OFFSET_STORAGE_REPLICATION_FACTOR: 1
STATUS_STORAGE_REPLICATION_FACTOR: 1
# Topic creation settings
CONNECT_TOPIC_CREATION_ENABLE: "true"
# Configure the number of partitions for auto-created topics
CONNECT_TOPIC_CREATION_DEFAULT_PARTITIONS: 3
CONNECT_TOPIC_CREATION_DEFAULT_REPLICATION_FACTOR: 1
# Worker settings
CONNECT_REST_ADVERTISED_HOST_NAME: kafka-connect
CONNECT_REST_PORT: 8083
CONNECT_PLUGIN_PATH: "/kafka/connect,/usr/share/java"
# Key and value converters
CONNECT_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_KEY_CONVERTER_SCHEMAS_ENABLE: "false"
CONNECT_VALUE_CONVERTER_SCHEMAS_ENABLE: "false"
# Internal key and value converters (for offset/config storage)
CONNECT_INTERNAL_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_INTERNAL_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
# Logging
CONNECT_LOG4J_ROOT_LOGLEVEL: INFO
CONNECT_LOG4J_LOGGERS: org.apache.zookeeper=ERROR,org.I0Itec.zkclient=ERROR,org.reflections=ERROR
volumes:
- ./kafka-connect/connectors:/etc/kafka-connect/connectors
restart: unless-stopped
# Database Services
postgres:
image: postgres:15
container_name: postgres-db
hostname: postgres-db
ports:
- "5434:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: gerges1020
POSTGRES_DB: postgres
POSTGRES_MULTIPLE_DATABASES: outbox,outbox_write,outbox_read
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init-multiple-databases.sh:/docker-entrypoint-initdb.d/init-multiple-databases.sh
- ./postgres-config/postgresql.conf:/etc/postgresql/postgresql.conf
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
interval: 10s
timeout: 5s
retries: 5
# Monitoring Services
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ../prometheus:/etc/prometheus
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
- '--web.enable-admin-api'
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin123
- GF_USERS_ALLOW_SIGN_UP=false
- GF_INSTALL_PLUGINS=grafana-piechart-panel
volumes:
- grafana-data:/var/lib/grafana
- ../grafana/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml
- ../grafana/dashboards.yml:/etc/grafana/provisioning/dashboards/dashboards.yml
- ../grafana/dashboards:/var/lib/grafana/dashboards
depends_on:
- prometheus
restart: unless-stopped
# Nginx Load Balancer
nginx:
image: nginx:alpine
container_name: nginx-lb
ports:
- "8090:80" # HTTP load balancer
- "50051:50051" # gRPC load balancer
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- service-a-1
- service-a-2
- service-a-3
restart: unless-stopped
# Application Services - 3 instances
service-a-1:
build:
context: ../Service-A
dockerfile: Dockerfile
container_name: service-a-1
hostname: service-a-1 # Set container hostname
ports:
- "8081:8080" # HTTP API port
- "50052:50051" # gRPC port
- "9094:9091" # Metrics port
depends_on:
- kafka
- prometheus
- postgres
environment:
KAFKA_BROKERS: "kafka:29092"
DB_URL: "postgresql://postgres:gerges1020@postgres:5432/outbox?sslmode=disable"
SERVICE_NAME: "service-a-1" # Add service name environment variable
networks:
- default
restart: unless-stopped
service-a-2:
build:
context: ../Service-A
dockerfile: Dockerfile
container_name: service-a-2
hostname: service-a-2 # Set container hostname
ports:
- "8083:8080" # HTTP API port
- "50053:50051" # gRPC port
- "9095:9091" # Metrics port
depends_on:
- kafka
- prometheus
- postgres
environment:
KAFKA_BROKERS: "kafka:29092"
DB_URL: "postgresql://postgres:gerges1020@postgres:5432/outbox?sslmode=disable"
SERVICE_NAME: "service-a-2" # Add service name environment variable
networks:
- default
restart: unless-stopped
service-a-3:
build:
context: ../Service-A
dockerfile: Dockerfile
container_name: service-a-3
hostname: service-a-3 # Set container hostname
ports:
- "8084:8080" # HTTP API port
- "50054:50051" # gRPC port
- "9096:9091" # Metrics port
depends_on:
- kafka
- prometheus
- postgres
environment:
KAFKA_BROKERS: "kafka:29092"
DB_URL: "postgresql://postgres:gerges1020@postgres:5432/outbox?sslmode=disable"
SERVICE_NAME: "service-a-3" # Add service name environment variable
networks:
- default
restart: unless-stopped
service-b:
build:
context: ../Service-B
dockerfile: Dockerfile
container_name: service-b
ports:
- "8082:8082"
- "9093:9092" # Changed external port to 9093 to avoid conflict with Kafka
depends_on:
- kafka
- nginx
- postgres
environment:
SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS: "kafka:29092"
SERVER_PORT: 8082
SPRING_DATASOURCE_LEADER_URL: "jdbc:postgresql://postgres:5432/outbox_write"
SPRING_DATASOURCE_LEADER_USERNAME: "postgres"
SPRING_DATASOURCE_LEADER_PASSWORD: "gerges1020"
SPRING_DATASOURCE_LEADER_DRIVER_CLASS_NAME: "org.postgresql.Driver"
SPRING_DATASOURCE_REPLICA_URL: "jdbc:postgresql://postgres:5432/outbox_read"
SPRING_DATASOURCE_REPLICA_USERNAME: "postgres"
SPRING_DATASOURCE_REPLICA_PASSWORD: "gerges1020"
SPRING_DATASOURCE_REPLICA_DRIVER_CLASS_NAME: "org.postgresql.Driver"
networks:
- default
restart: unless-stopped
volumes:
prometheus-data:
grafana-data:
postgres-data:
networks:
default:
name: DMA # Default network for all services