Added an executable README.sh, that demonstrates the example
authorKai Moritz <kai@juplo.de>
Sun, 1 Nov 2020 16:41:06 +0000 (17:41 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 1 Nov 2020 18:05:03 +0000 (19:05 +0100)
README.sh [new file with mode: 0755]

diff --git a/README.sh b/README.sh
new file mode 100755 (executable)
index 0000000..6a4ef4c
--- /dev/null
+++ b/README.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+if [ "$1" = "cleanup" ]
+then
+  docker-compose down -v
+  mvn clean
+  docker image rm juplo/jdbc:outbox
+  docker image rm juplo/outbox:polling
+  exit
+fi
+
+if [[
+  $(docker image ls -q juplo/jdbc:outbox) == "" ||
+  $(docker image ls -q juplo/outbox:polling) == "" ||
+  "$1" = "build"
+]]
+then
+  mvn package || exit
+else
+  echo "Using image existing images:"
+  docker image ls juplo/jdbc:outbox
+  docker image ls juplo/outbox:polling
+fi
+
+trap 'kill $(jobs -p)' EXIT
+
+docker-compose up -d zookeeper kafka
+
+while ! [[ $(zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]];
+do
+  echo "Waiting for kafka...";
+  sleep 1;
+done
+
+kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic outbox
+
+
+docker-compose up -d jdbc outbox
+
+while ! [[ $(http :8080/actuator/health 2>/dev/null | jq -r .status) == "UP" ]];
+do
+  echo "Waiting for User-Service...";
+  sleep 1;
+done
+
+
+kafkacat -C -b localhost:9092 -t outbox &
+
+echo peter | http :8080/users
+echo franz | http :8080/users
+echo beate | http :8080/users
+http :8080/users
+http DELETE :8080/users/franz
+http :8080/users