-
Notifications
You must be signed in to change notification settings - Fork 20
/
Dockerfile
55 lines (41 loc) · 1.43 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
FROM openjdk:8-jre-alpine
MAINTAINER Enrique Garcia <[email protected]>
ARG KAFKA_HOME=/opt/kafka
ARG KAFKA_USER=kafka
ARG KAFKA_GROUP=kafka
ARG KAFKA_VERSION="2.5.0"
ARG SCALA_VERSION="2.13"
ENV KAFKA_HOME=${KAFKA_HOME} \
KAFKA_VERSION=${KAFKA_VERSION} \
SCALA_VERSION=${SCALA_VERSION} \
KAFKA_ZK_LOCAL=true \
KAFKA_REPLICAS=1 \
KAFKA_USER=$KAFKA_USER \
KAFKA_GROUP=$KAFKA_GROUP \
KAFKA_DATA_DIR=$KAFKA_HOME/data \
SERVER_port=9092 \
ZK_clientPort=2181
# Required packages
RUN apk add --update --no-cache \
bash tar gnupg openssl ca-certificates sudo
# Download kafka distribution under KAFKA_HOME directory
ADD kafka_download.sh /tmp/
RUN mkdir -p $KAFKA_HOME \
&& chmod a+x /tmp/kafka_download.sh
RUN /tmp/kafka_download.sh
RUN rm -rf /tmp/kafka_download.sh \
&& apk del gnupg
# Add custom scripts and configure user
ADD kafka_*.sh $KAFKA_HOME/bin/
RUN addgroup -S -g 1001 $KAFKA_GROUP \
&& adduser -h $KAFKA_HOME -g "Kafka user" -u 1001 -D -S -G $KAFKA_GROUP $KAFKA_USER \
&& chown -R $KAFKA_USER:$KAFKA_GROUP $KAFKA_HOME \
&& chmod a+x $KAFKA_HOME/bin/kafka_*.sh \
&& chmod -R a+w $KAFKA_HOME \
&& ln -s $KAFKA_HOME/bin/kafka_*.sh /usr/bin \
&& echo "${KAFKA_USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER $KAFKA_USER
WORKDIR $KAFKA_HOME/bin/
EXPOSE $ZK_port $SERVER_port
HEALTHCHECK --interval=10s --retries=10 CMD "kafka_server_status.sh"
CMD kafka_server.sh start