├── .gitignore ├── confluent.repo ├── README.md ├── Dockerfile ├── log4j.properties ├── LICENSE └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /confluent.repo: -------------------------------------------------------------------------------- 1 | [confluent-1.0] 2 | name=Confluent repository for 1.x packages 3 | baseurl=http://packages.confluent.io/rpm/1.0 4 | gpgcheck=1 5 | gpgkey=http://packages.confluent.io/rpm/1.0/archive.key 6 | enabled=1 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dockerfile for Apache Kafka 2 | 3 | Built images are hosted at https://registry.hub.docker.com/u/state/kafka 4 | 5 | # Configuration 6 | 7 | Via environment variables: 8 | 9 | - `KAFKA_BROKER_ID` 10 | - `KAFKA_ZOOKEEPER_CONNECT` 11 | - `KAFKA_ADVERTISED_HOST` 12 | - `KAFKA_ADVERTISED_PORT` 13 | - `KAFKA_LOG_CLEANER` 14 | - `KAFKA_AUTO_CREATE_TOPICS` - default is `true` 15 | 16 | # License 17 | 18 | See LICENSE 19 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM state/oraclejre:1.8.0_40 2 | 3 | ADD ./confluent.repo /etc/yum.repos.d/ 4 | 5 | RUN yum update -y -q; yum clean all 6 | 7 | # Set timezone to UTC until upstream fixes that 8 | RUN ln -s -f /usr/share/zoneinfo/Etc/UTC /etc/localtime 9 | 10 | ENV SCALA_VERSION 2.10.4 11 | ENV KAFKA_VERSION 0.8.2.0-1 12 | 13 | RUN rpm --import http://packages.confluent.io/rpm/1.0/archive.key && \ 14 | yum install -y confluent-kafka-$SCALA_VERSION-$KAFKA_VERSION && \ 15 | yum clean all 16 | 17 | WORKDIR /srv/kafka 18 | VOLUME /data 19 | 20 | ADD run.sh /run.sh 21 | ADD log4j.properties /etc/kafka/log4j.properties 22 | 23 | CMD ["/run.sh"] 24 | -------------------------------------------------------------------------------- /log4j.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | kafka.logs.dir=logs 17 | 18 | log4j.rootLogger=INFO, stdout 19 | log4j.logger.kafka=INFO, stdout 20 | 21 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 22 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n 24 | 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Equal Media Limited 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | : ${KAFKA_BROKER_ID} 4 | : ${KAFKA_ZOOKEEPER_CONNECT} 5 | : ${KAFKA_PORT} 6 | : ${KAFKA_ADVERTISED_HOST} 7 | : ${KAFKA_ADVERTISED_PORT} 8 | : ${KAFKA_LOG_CLEANER} 9 | : ${KAFKA_AUTO_CREATE_TOPICS:=true} 10 | : ${KAFKA_ENABLE_DELETE_TOPICS:=true} 11 | 12 | KAFKA_CONFIG=/etc/kafka/server.properties 13 | 14 | if [[ -n ${KAFKA_BROKER_ID} ]]; then 15 | sed -e "s/broker.id=.*/broker.id=${KAFKA_BROKER_ID}/" \ 16 | -i $KAFKA_CONFIG 17 | fi 18 | 19 | if [[ -n ${KAFKA_ZOOKEEPER_CONNECT} ]]; then 20 | sed -e "s/^zookeeper.connect=.*/zookeeper.connect=${KAFKA_ZOOKEEPER_CONNECT}/" \ 21 | -i $KAFKA_CONFIG 22 | fi 23 | 24 | if [[ -n ${KAFKA_PORT} ]]; then 25 | sed -e "s/^port=.*/port=${KAFKA_PORT}/" \ 26 | -i $KAFKA_CONFIG 27 | fi 28 | 29 | if [[ -n ${KAFKA_ADVERTISED_HOST} ]]; then 30 | sed -e "s/^#advertised.host.name=.*/advertised.host.name=${KAFKA_ADVERTISED_HOST}/" \ 31 | -i $KAFKA_CONFIG 32 | fi 33 | 34 | if [[ -n ${KAFKA_ADVERTISED_PORT} ]]; then 35 | sed -e "s/^#advertised.port=.*/advertised.port=${KAFKA_ADVERTISED_PORT}/" \ 36 | -i $KAFKA_CONFIG 37 | fi 38 | 39 | if [[ -n ${KAFKA_LOG_CLEANER} ]]; then 40 | sed -e "s/^log.cleaner.enable=.*/log.cleaner.enable=${KAFKA_LOG_CLEANER}/" \ 41 | -i $KAFKA_CONFIG 42 | fi 43 | 44 | sed -e 's|^log.dirs=.*|log.dirs=/data|' -i $KAFKA_CONFIG 45 | echo "auto.create.topics.enable=${KAFKA_AUTO_CREATE_TOPICS}" >> $KAFKA_CONFIG 46 | 47 | echo "delete.topic.enable=${KAFKA_ENABLE_DELETE_TOPICS}" >> $KAFKA_CONFIG 48 | 49 | if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then 50 | exec /bin/kafka-server-start $KAFKA_CONFIG "$@" 51 | fi 52 | 53 | exec "$@" 54 | --------------------------------------------------------------------------------