From: Kai Moritz Date: Sun, 11 Jun 2023 07:40:54 +0000 (+0200) Subject: Docker-Setup in das Unterverzeichnis `docker` verschoben X-Git-Tag: first-contact-DEPRECATED~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ee5042122da662e570fdf234bb794f91ab891863;p=demos%2Fkafka%2Ftraining Docker-Setup in das Unterverzeichnis `docker` verschoben --- diff --git a/README.sh b/README.sh index 0ee50a9..7ddfbbf 100755 --- a/README.sh +++ b/README.sh @@ -2,7 +2,7 @@ if [ "$1" = "cleanup" ] then - docker-compose down -v + docker-compose -f docker/docker-compose.yml down -v mvn clean exit fi @@ -12,10 +12,10 @@ if [ "$1" = "build" ]; then exit; fi trap 'kill $(jobs -p) 2>/dev/null' EXIT -docker-compose up -d +docker-compose -f docker/docker-compose.yml up -d echo "Waiting for the Kafka-Cluster to become ready..." -docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1 +docker-compose -f docker/docker-compose.yml exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1 echo "Producing messages" mvn exec:java@producer diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index ec307f5..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,37 +0,0 @@ -version: '3.2' -services: - zookeeper: - image: confluentinc/cp-zookeeper:7.1.3 - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - ports: - - 2181:2181 - - kafka: - image: confluentinc/cp-kafka:7.1.3 - environment: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9082 - KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka:9092, LOCALHOST://localhost:9082 - KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" - ports: - - 9092:9082 - - 9082:9082 - depends_on: - - zookeeper - - setup: - image: juplo/toolbox - command: > - bash -c " - kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test - kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 - " - - cli: - image: juplo/toolbox - command: sleep infinity diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..ec307f5 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,37 @@ +version: '3.2' +services: + zookeeper: + image: confluentinc/cp-zookeeper:7.1.3 + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + ports: + - 2181:2181 + + kafka: + image: confluentinc/cp-kafka:7.1.3 + environment: + KAFKA_BROKER_ID: 1 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_LISTENERS: DOCKER://:9092, LOCALHOST://:9082 + KAFKA_ADVERTISED_LISTENERS: DOCKER://kafka:9092, LOCALHOST://localhost:9082 + KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER:PLAINTEXT, LOCALHOST:PLAINTEXT + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" + ports: + - 9092:9082 + - 9082:9082 + depends_on: + - zookeeper + + setup: + image: juplo/toolbox + command: > + bash -c " + kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test + kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 + " + + cli: + image: juplo/toolbox + command: sleep infinity