From 0386d902ca6d9b0c2872fc0ad8fb7012f1bbeb97 Mon Sep 17 00:00:00 2001 From: Brian Towles Date: Mon, 8 Feb 2016 12:36:24 -0600 Subject: [PATCH 1/2] - Added dockerize to platform to allow containers to wait for services to be available - Added docker-compose file for single command ordered start-up. --- confluent-platform/Dockerfile | 6 ++++- docker-compose.yml | 30 +++++++++++++++++++++++ kafka/kafka-docker.sh | 3 +++ rest-proxy/rest-proxy-docker.sh | 5 ++++ schema-registry/schema-registry-docker.sh | 4 +++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/confluent-platform/Dockerfile b/confluent-platform/Dockerfile index b504148..86c8daf 100644 --- a/confluent-platform/Dockerfile +++ b/confluent-platform/Dockerfile @@ -7,6 +7,7 @@ FROM debian:8.2 ENV SCALA_VERSION="2.10.4" ENV JAVA_VERSION="7" ENV CONFLUENT_MAJOR_VERSION="1.0" +ENV DOCKERIZE_VERSION="v0.2.0" RUN apt-get update && \ apt-get upgrade -y && \ @@ -14,4 +15,7 @@ RUN apt-get update && \ curl -SL http://packages.confluent.io/deb/${CONFLUENT_MAJOR_VERSION}/archive.key | apt-key add - && \ echo "deb [arch=all] http://packages.confluent.io/deb/${CONFLUENT_MAJOR_VERSION} stable main" >> /etc/apt/sources.list && \ apt-get update && \ - apt-get install -y confluent-platform-${SCALA_VERSION} + apt-get install -y confluent-platform-${SCALA_VERSION} &&\ + curl -o /tmp/dockerize.tar.gz -sSL "https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz" &&\ + tar -C /usr/local/bin -xzvf /tmp/dockerize.tar.gz &&\ + rm -rf /tmp/dockerize.tar.gz diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7ac2f88 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +zookeeper: + image: confluent/zookeeper + ports: + - "2181" + +schema-registry: + image: confluent/schema-registry + ports: + - "8081:8081" + links: + - zookeeper + - kafka + +rest-proxy: + image: confluent/rest-proxy + ports: + - "8082:8082" + links: + - zookeeper + - kafka + - schema-registry + +kafka: + image: confluent/kafka + ports: + - "9092:9092" + links: + - zookeeper + environment: + KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100 diff --git a/kafka/kafka-docker.sh b/kafka/kafka-docker.sh index eea705e..8512737 100755 --- a/kafka/kafka-docker.sh +++ b/kafka/kafka-docker.sh @@ -20,6 +20,7 @@ kafka_cfg_file="/etc/kafka/server.properties" : ${KAFKA_ZOOKEEPER_CONNECTION_TIMEOUT_MS:=6000} : ${KAFKA_AUTO_CREATE_TOPICS_ENABLE:=true} : ${KAFKA_DELETE_TOPIC_ENABLE:=true} +: ${ZOOKEEPER_PORT=tcp://$KAFKA_ZOOKEEPER_CONNECT} export KAFKA_BROKER_ID export KAFKA_PORT @@ -59,4 +60,6 @@ done export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/etc/kafka/log4j.properties" +dockerize -wait $ZOOKEEPER_PORT + exec /usr/bin/kafka-server-start ${kafka_cfg_file} diff --git a/rest-proxy/rest-proxy-docker.sh b/rest-proxy/rest-proxy-docker.sh index 2d4c9ed..5b716f6 100755 --- a/rest-proxy/rest-proxy-docker.sh +++ b/rest-proxy/rest-proxy-docker.sh @@ -7,6 +7,9 @@ rp_cfg_file="/etc/kafka-rest/kafka-rest.properties" : ${RP_SCHEMA_REGISTRY_URL:=http://$SCHEMA_REGISTRY_PORT_8081_TCP_ADDR:$SCHEMA_REGISTRY_PORT_8081_TCP_PORT} : ${RP_ZOOKEEPER_CONNECT:=$ZOOKEEPER_PORT_2181_TCP_ADDR:$ZOOKEEPER_PORT_2181_TCP_PORT} : ${RP_DEBUG:=false} +: ${SCHEMA_REGISTRY_PORT:=$RP_SCHEMA_REGISTRY_URL} +: ${KAFKA_PORT:=tcp://$KAFKA_PORT_9092_TCP_ADDR:$KAFKA_PORT_9092_TCP_PORT} +: ${ZOOKEEPER_PORT:=tcp://$RP_ZOOKEEPER_CONNECT} export RP_ID export RP_PORT @@ -34,4 +37,6 @@ done # Fix for issue #77, PR #78: https://github.com/confluentinc/kafka-rest/pull/78/files sed -i 's/\"kafka\"//' /usr/bin/kafka-rest-run-class +dockerize -wait $SCHEMA_REGISTRY_PORT -wait $KAFKA_PORT -wait $ZOOKEEPER_PORT + exec /usr/bin/kafka-rest-start ${rp_cfg_file} diff --git a/schema-registry/schema-registry-docker.sh b/schema-registry/schema-registry-docker.sh index 0bff6ec..15af4bf 100755 --- a/schema-registry/schema-registry-docker.sh +++ b/schema-registry/schema-registry-docker.sh @@ -6,6 +6,8 @@ sr_cfg_file="/etc/schema-registry/schema-registry.properties" : ${SCHEMA_REGISTRY_KAFKASTORE_TOPIC:=_schemas} : ${SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL:=$ZOOKEEPER_PORT_2181_TCP_ADDR:$ZOOKEEPER_PORT_2181_TCP_PORT} : ${SCHEMA_REGISTRY_DEBUG:=false} +: ${KAFKA_PORT:=tcp://$KAFKA_PORT_9092_TCP_ADDR:$KAFKA_PORT_9092_TCP_PORT} +: ${ZOOKEEPER_PORT:=tcp://$SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL} export SCHEMA_REGISTRY_PORT export SCHEMA_REGISTRY_KAFKASTORE_TOPIC @@ -29,4 +31,6 @@ for var in $(env | grep '^SCHEMA_REGISTRY_' | sort); do echo "${key}=${value}" >> ${sr_cfg_file} done +dockerize -wait $ZOOKEEPER_PORT -wait $KAFKA_PORT + exec /usr/bin/schema-registry-start ${sr_cfg_file} From 17e9eb8cdca54b2f1c6487a7d8a3adc6586a5424 Mon Sep 17 00:00:00 2001 From: Brian Towles Date: Mon, 8 Feb 2016 12:51:41 -0600 Subject: [PATCH 2/2] - Removed local test hostname --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7ac2f88..0820af5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,5 +26,3 @@ kafka: - "9092:9092" links: - zookeeper - environment: - KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100