#!/bin/bash
+FORTUNE=juplo/wordcount--fortune:1.0.0
RECORDER=juplo/wordcount--recorder:1.0.0
USERS=juplo/wordcount--users:1.0.0
COUNTER=juplo/wordcount--counter:1.0.0
if [ "$1" = "cleanup" ]
then
docker-compose down -v
+ docker image rm $FORTUNE
docker image rm $RECORDER
docker image rm $USERS
docker image rm $COUNTER
fi
if [[
+ $(docker image ls -q $FORTUNE) == "" ||
$(docker image ls -q $RECORDER) == "" ||
$(docker image ls -q $USERS) == "" ||
$(docker image ls -q $COUNTER) == "" ||
git submodule update --init
mvn clean package || exit
docker-compose rm -svf recorder users counter top10 query
+ ( cd fortune; ./README.sh $FORTUNE; )
mvn -f recorder/pom.xml docker:build
mvn -f users/pom.xml docker:build
mvn -f counter/pom.xml docker:build
mvn -f query/pom.xml docker:build
else
echo "Using existing images:"
+ docker image ls $FORTUNE
docker image ls $RECORDER
docker image ls $USERS
docker image ls $COUNTER
docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
docker-compose exec cli zookeeper-shell zookeeper:2181 ls /brokers/ids
+docker-compose up -d users
+while [ "$(http :8082/actuator/health | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service users..."; sleep 1; done
+http -v post :8082/users username=bart firstName=Bart lastName=Simpson sex=MALE
+http -v post :8082/users username=nerd firstName=Jane lastName=Doe sex=FEMALE
+http -v post :8082/users username=riddler firstName=Rumpel lastName=Stilzchen sex=MALE
+
echo "Starting all instances..."
docker-compose up -d
depends_on:
- kafka
+ bart:
+ image: juplo/wordcount--fortune:1.0.0
+ command: bash -c "
+ while [ true ];
+ do
+ /usr/games/fortune chalkboard
+ | head -1
+ | http -v recorder:8080/bart;
+ echo;
+ sleep 1;
+ done"
+
+ nerd:
+ image: juplo/wordcount--fortune:1.0.0
+ command: bash -c "
+ while [ true ];
+ do
+ /usr/games/fortune computers
+ | grep -v '^[[:space:]]*--'
+ | http -v recorder:8080/nerd;
+ echo;
+ sleep 1;
+ done"
+
+ riddler:
+ image: juplo/wordcount--fortune:1.0.0
+ command: bash -c "
+ while [ true ];
+ do
+ /usr/games/fortune riddles
+ | awk -F':' '/^Q/ { print $$2 }'
+ | http -v recorder:8080/riddler;
+ echo;
+ sleep 1;
+ done"
+
cli:
image: confluentinc/cp-kafka:6.2.0
command: bash -c "