diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..171763c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM docker:stable + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 549ceca..53dce93 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # kafka-actions -Action to install kafka + +This [GitHub Action](https://github.com/features/actions) sets up Bitnami Kafka instance. + +Inspired by https://github.com/getong/rabbitmq-action, @getong Thanks! + +--------- +## Usage + +See [action.yml](action.yml) + + +--------- +## License + +The scripts and documentation in this project are released under the [MIT License](LICENSE) \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..87dd854 --- /dev/null +++ b/action.yml @@ -0,0 +1,23 @@ +name: 'Setup Bitnami Kafka' +description: 'Setup Bitnami Kafka' +author: 'bbccorp' +inputs: + kafka version: + description: 'Version of Bitnami Kafka to use' + required: false + default: 'latest' + zookeeper version: + description: 'Version of Bitnami Zookeeper to use' + required: false + default: 'latest' + kafka port: + description: 'The port of Kafka host' + required: false + default: 9092 + zookeeper port: + description: 'The port of Zookeeper host' + required: false + default: 2181 +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..497cd70 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +docker_run="docker run" + +run_zookeeper="$docker_run -d -p $INPUT_ZOOKEEPER_PORT:2181 -e ALLOW_ANONYMOUS_LOGIN=yes bitnami/zookeeper:$INPUT_ZOOKEEPER_VERSION" +sh -c "$run_zookeeper" + +run_kafka="$docker_run -d -p $INPUT_KAFKA_PORT:9092 -e KAFKA_BROKER_ID=1 -e KAFKA_LISTENERS=PLAINTEXT://:9092 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 -e ALLOW_PLAINTEXT_LISTENER=yes -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 bitnami/kafka:$INPUT_KAFKA_VERSION" +sh -c "$run_kafka"