-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathre-build.sh
65 lines (51 loc) · 1.42 KB
/
re-build.sh
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
#!/bin/bash
JAEGER_NAME="jaeger"
validate_network() {
networkController=false;
for networkName in $(docker network ls --format '{{.Name}}')
do
if [ "$networkName" = "trace" ]
then
networkController=true;
fi
done
if [ "$networkController" = false ]
then
docker network create trace
fi
}
validate_jaeger() {
if [ "$(docker ps --filter name="$JAEGER_NAME" --format '{{.Names}}')" = "$JAEGER_NAME" ]
then
docker network connect trace jaeger
fi
}
validate_zookeeper() {
zookeeperMode=""
while [ "$zookeeperMode" = "" ]
do
zookeeperMode=$(docker run --network=trace --rm confluentinc/cp-zookeeper:5.5.1 bash -c "echo stat | nc zookeeper 2181 | grep Mode")
done
}
validate_kafka() {
kafkaStart=""
while [ "$kafkaStart" = "" ]
do
kafkaStart=$(docker logs kafka | grep started)
done
}
# Start zookeeper
validate_zookeeper
# Start kafka
validate_kafka
# clean up old image first to be safe
docker stop kafkaproducer kafkaconsumer
docker rmi "$(docker images -q -f 'label=kafkaclient')"
# Build
docker build -t mykafka .
# run the Producer container
docker run -d --rm --network="trace" --name kafkaproducer mykafka com.dynatrace.kafka.KafkaProducerExample
# run the Consumer container
docker run -d --rm --network="trace" --name kafkaconsumer mykafka com.dynatrace.kafka.KafkaConsumerExample
#Cleaning builder image
docker rmi "$(docker images -q -f 'label=autodelete=true')"