-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
323 lines (282 loc) · 9.08 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
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
version: "3.8"
networks:
lorry-dev:
name: lorry-dev
driver: bridge
services:
# ------------
# Apache Flink
# ------------
# https://ci.apache.org/projects/flink/flink-docs-master/docs/deployment/resource-providers/standalone/docker/#flink-with-docker-compose
flink-jobmanager:
command: jobmanager
environment:
- |
FLINK_PROPERTIES=
jobmanager.rpc.address: flink-jobmanager
image: flink:${FLINK_VERSION}
networks:
- lorry-dev
ports:
- "${PORT_FLINK_JOBMANAGER}:${PORT_FLINK_JOBMANAGER}"
# Define health check for Apache Flink jobmanager.
healthcheck:
test: [ "CMD", "curl", "--fail", "http://localhost:${PORT_FLINK_JOBMANAGER}/overview" ]
start_period: 3s
interval: 3s
timeout: 30s
retries: 60
flink-taskmanager:
command: taskmanager
image: flink:${FLINK_VERSION}
environment:
- |
FLINK_PROPERTIES=
jobmanager.rpc.address: flink-jobmanager
taskmanager.numberOfTaskSlots: 2
networks:
- lorry-dev
deploy:
replicas: 1
depends_on:
- flink-jobmanager
# ------------------------
# Apache Kafka (Confluent)
# ------------------------
# https://hub.docker.com/u/confluentinc
# https://docs.confluent.io/platform/current/installation/docker/config-reference.html
# https://gist.github.com/everpeace/7a317860cab6c7fb39d5b0c13ec2543e
# https://github.com/framiere/a-kafka-story/blob/master/step14/docker-compose.yml
kafka-zookeeper:
image: confluentinc/cp-zookeeper:${CONFLUENT_VERSION}
environment:
ZOOKEEPER_CLIENT_PORT: ${PORT_KAFKA_ZOOKEEPER}
KAFKA_OPTS: -Dzookeeper.4lw.commands.whitelist=ruok
networks:
- lorry-dev
# Define health check for Zookeeper.
healthcheck:
# https://github.com/confluentinc/cp-docker-images/issues/827
test: ["CMD", "bash", "-c", "echo ruok | nc localhost ${PORT_KAFKA_ZOOKEEPER} | grep imok"]
start_period: 3s
interval: 3s
timeout: 30s
retries: 60
kafka-broker:
image: confluentinc/cp-kafka:${CONFLUENT_VERSION}
environment:
KAFKA_ZOOKEEPER_CONNECT: kafka-zookeeper:${PORT_KAFKA_ZOOKEEPER}
KAFKA_LISTENERS: INTERNAL://0.0.0.0:${PORT_KAFKA_BROKER_INTERNAL},EXTERNAL://0.0.0.0:${PORT_KAFKA_BROKER_EXTERNAL}
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka-broker:${PORT_KAFKA_BROKER_INTERNAL},EXTERNAL://localhost:${PORT_KAFKA_BROKER_EXTERNAL}
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
networks:
- lorry-dev
ports:
- "${PORT_KAFKA_BROKER_INTERNAL}:${PORT_KAFKA_BROKER_INTERNAL}"
- "${PORT_KAFKA_BROKER_EXTERNAL}:${PORT_KAFKA_BROKER_EXTERNAL}"
depends_on:
- kafka-zookeeper
# Define health check for Kafka broker.
healthcheck:
#test: ps augwwx | egrep "kafka.Kafka"
test: ["CMD", "nc", "-vz", "localhost", "${PORT_KAFKA_BROKER_INTERNAL}"]
start_period: 3s
interval: 3s
timeout: 30s
retries: 60
# The Kafka schema registry as well as ksqlDB is not needed for this setup.
#kafka-schema-registry:
# image: confluentinc/cp-schema-registry:${CONFLUENT_VERSION}
#kafka-ksqldb:
# image: confluentinc/cp-ksqldb-server:${CONFLUENT_VERSION}
# -------
# CrateDB
# -------
# https://hub.docker.com/crate/_crate
cratedb:
command: ["crate",
"-Cdiscovery.type=single-node",
"-Ccluster.routing.allocation.disk.threshold_enabled=false",
]
environment:
CRATE_HEAP_SIZE: 2g
image: crate:${CRATEDB_VERSION}
networks:
- lorry-dev
ports:
- "${CRATEDB_HTTP_PORT}:${CRATEDB_HTTP_PORT}"
- "${CRATEDB_POSTGRESQL_PORT}:${CRATEDB_POSTGRESQL_PORT}"
# Define health check for CrateDB.
healthcheck:
test: [ "CMD", "curl", "--fail", "http://localhost:${CRATEDB_HTTP_PORT}" ]
start_period: 3s
interval: 3s
timeout: 30s
retries: 60
# --------
# GarageMQ
# --------
garagemq:
image: xyzj/garagemq:${GARAGEMQ_VERSION}
networks:
- lorry-dev
ports:
- "${PORT_GARAGEMQ}:${PORT_GARAGEMQ}"
# Define health check for Mosquitto.
healthcheck:
test: [ "CMD", "amqp-consume", "--exclusive", "--queue=foo", "--count=0", "cat" ]
start_period: 1s
interval: 3s
timeout: 10s
retries: 60
deploy:
replicas: 0
# ---------
# Mosquitto
# ---------
# https://hub.docker.com/_/eclipse-mosquitto
mosquitto:
command: ["mosquitto", "-c", "/mosquitto-no-auth.conf"]
image: eclipse-mosquitto:${MOSQUITTO_VERSION}
networks:
- lorry-dev
ports:
- "${PORT_MOSQUITTO}:${PORT_MOSQUITTO}"
# Define health check for Mosquitto.
healthcheck:
test: [ "CMD", "mosquitto_sub", "-v", "-t", "foobar", "-E" ]
start_period: 1s
interval: 3s
timeout: 10s
retries: 60
# --------
# RabbitMQ
# --------
# https://hub.docker.com/_/rabbitmq
rabbitmq:
image: rabbitmq:${RABBITMQ_VERSION}-management
networks:
- lorry-dev
ports:
- "${PORT_RABBITMQ_AMQP}:${PORT_RABBITMQ_AMQP}"
- "${PORT_RABBITMQ_MANAGEMENT}:${PORT_RABBITMQ_MANAGEMENT}"
# Define health check for Mosquitto.
healthcheck:
test: [ "CMD", "rabbitmqctl", "status" ]
start_period: 1s
interval: 3s
timeout: 10s
retries: 60
# -------
# Bundler
# -------
# Wait for all defined services to be fully available by probing their health
# status, even when using `docker compose up --detach`.
# https://marcopeg.com/2019/docker-compose-healthcheck/
start-dependencies:
image: dadarek/wait-for-dependencies
depends_on:
cratedb:
condition: service_healthy
flink-jobmanager:
condition: service_healthy
kafka-broker:
condition: service_healthy
mosquitto:
condition: service_healthy
rabbitmq:
condition: service_healthy
# -----
# Tasks
# -----
# Create database table in CrateDB.
create-table:
image: westonsteimel/httpie
networks: [lorry-dev]
command: http "${CRATEDB_HTTP_URL}/_sql?pretty" stmt='CREATE TABLE "taxi_rides" ("payload" OBJECT(DYNAMIC))' --ignore-stdin
deploy:
replicas: 0
# Create Kafka topic.
create-topic:
image: confluentinc/cp-kafka:${CONFLUENT_VERSION}
networks: [lorry-dev]
command: kafka-topics --bootstrap-server kafka-broker:${PORT_KAFKA_BROKER_INTERNAL} --create --if-not-exists --replication-factor 1 --partitions 1 --topic rides
deploy:
replicas: 0
# Delete Kafka topic.
delete-topic:
image: confluentinc/cp-kafka:${CONFLUENT_VERSION}
networks: [lorry-dev]
command: kafka-topics --bootstrap-server kafka-broker:${PORT_KAFKA_BROKER_INTERNAL} --delete --if-exists --topic rides
deploy:
replicas: 0
# Acquire Flink job JAR file.
download-job:
image: apteno/alpine-jq
networks: [lorry-dev]
command: >
wget ${FLINK_JOB_JAR_URL} --output-document /src/${FLINK_JOB_JAR_FILE}
deploy:
replicas: 0
# Drop database table in CrateDB.
drop-table:
image: westonsteimel/httpie
networks: [lorry-dev]
command: http "${CRATEDB_HTTP_URL}/_sql?pretty" stmt='DROP TABLE "taxi_rides"' --ignore-stdin
deploy:
replicas: 0
# Invoke HTTPie via Docker.
httpie:
image: westonsteimel/httpie
networks: [lorry-dev]
deploy:
replicas: 0
# List running Flink jobs.
list-jobs:
image: flink:${FLINK_VERSION}
networks: [lorry-dev]
command: flink list --jobmanager=flink-jobmanager:${PORT_FLINK_JOBMANAGER}
deploy:
replicas: 0
# List job ids of running Flink jobs.
# TODO: Currently, this does not work, because `flink-jobmanager` fails to respond to our requests.
list-job-ids:
image: westonsteimel/httpie
networks: [lorry-dev]
command: http http://flink-jobmanager:${PORT_FLINK_JOBMANAGER}/jobs/overview Host:localhost --ignore-stdin | jq -r .jobs[].jid
deploy:
replicas: 0
# Publish data to Kafka topic.
publish-data:
image: confluentinc/cp-kafka:${CONFLUENT_VERSION}
networks: [lorry-dev]
command: kafka-console-producer --bootstrap-server kafka-broker:${PORT_KAFKA_BROKER_INTERNAL} --topic rides
deploy:
replicas: 0
# Submit Flink job.
submit-job:
image: flink:${FLINK_VERSION}
networks: [lorry-dev]
# Note: Remove `--detach` option to interactively receive stacktrace.
command: >
flink run
--jobmanager=flink-jobmanager:${PORT_FLINK_JOBMANAGER}
--detach
/src/${FLINK_JOB_JAR_FILE}
--kafka.servers kafka-broker:${PORT_KAFKA_BROKER_INTERNAL}
--kafka.topic rides
--crate.hosts "${CRATEDB_HOST}:${CRATEDB_POSTGRESQL_PORT}"
--crate.table taxi_rides
--crate.user '${CRATEDB_USERNAME}'
--crate.password '${CRATEDB_PASSWORD}'
deploy:
replicas: 0
# Subscribe to Kafka topic.
subscribe-topic:
image: edenhill/kcat:${KCAT_VERSION}
networks: [lorry-dev]
command: kcat -b kafka-broker -C -t rides -o end
deploy:
replicas: 0