-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
65 lines (48 loc) · 2.27 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM openjdk:8u121-jre-alpine
ENV KAFKA_VERSION=0.10.2.0 \
SCALA_VERSION=2.12 \
GPG_KEY=AB55EF5C \
KAFKA_HOME=/kafka
# Install required packages
RUN apk add --no-cache \
bash
# Download and install Kafka
RUN log () { echo -e "\033[01;95m$@\033[0m"; } && \
apk add --no-cache --virtual .build-deps \
gnupg \
tar && \
INSTALL_DIR="$(mktemp -d)" && \
export GNUPGHOME="$(mktemp -d)" && \
log "Download kafka archive and signature file" && \
wget -O "$INSTALL_DIR/kafka.tgz" "http://www.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$SCALA_VERSION-$KAFKA_VERSION.tgz" && \
wget -O "$INSTALL_DIR/kafka.tgz.asc" "http://www.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$SCALA_VERSION-$KAFKA_VERSION.tgz.asc" && \
log "Check the kafka archive signature" && \
# See http://www.apache.org/info/verification.html and http://kafka.apache.org/KEYS
wget -O "$INSTALL_DIR/KEYS" "http://kafka.apache.org/KEYS" && \
gpg --import "$INSTALL_DIR/KEYS" && \
gpg --batch --verify "$INSTALL_DIR/kafka.tgz.asc" "$INSTALL_DIR/kafka.tgz" && \
log "Unpack kafka" && \
mkdir $KAFKA_HOME && \
tar -xz --directory="$KAFKA_HOME" --strip-components=1 --file="$INSTALL_DIR/kafka.tgz" && \
log "Remove Windows files" && \
rm -r "$KAFKA_HOME/bin/windows" && \
log "Clean up" && \
rm -r "$INSTALL_DIR" "$GNUPGHOME" && \
apk del .build-deps
# Adjust the default server properties to connect to Zookeeper at zookeeper:2181
ENV ZOOKEEPER_HOST=zookeeper \
ZOOKEEPER_PORT=2181
RUN sed -i "s/zookeeper.connect=.*/zookeeper.connect=$ZOOKEEPER_HOST:$ZOOKEEPER_PORT/g" /kafka/config/server.properties
# Add wait-for-it script, for use in waiting for Zookeeper
ADD https://raw.githubusercontent.com/ucalgary/wait-for-it/master/wait-for-it.sh /usr/local/bin/wait-for-it
RUN chmod 755 /usr/local/bin/wait-for-it
WORKDIR $KAFKA_HOME
ENV PATH=$PATH:$KAFKA_HOME/bin
EXPOSE 9092
CMD wait-for-it -h $ZOOKEEPER_HOST -p $ZOOKEEPER_PORT -s -t 30 -- kafka-server-start.sh /kafka/config/server.properties
LABEL maintainer="King Chung Huang <[email protected]>" \
org.label-schema.schema-version="1.0" \
org.label-schema.name="Apache Kafka" \
org.label-schema.version="0.10.2.0" \
org.label-schema.url="https://kafka.apache.org" \
org.label-schema.vcs-url="https://github.com/ucalgary/docker-kafka"