kafka/Dockerfile

70 lines
4.0 KiB
Docker
Raw Permalink Normal View History

# Rx3-Docker/Kafka Dockerfile
#-------------------------------------------------------------------------------
ARG IMG_FROM_URL="rx3-docker/java:latest"
FROM ${IMG_FROM_URL}
ARG IMG_NAME
ARG IMG_NAME_FULL
ARG IMG_VERSION
ARG IMG_MAINTAINER
LABEL org.rx3.${IMG_NAME}.name=${IMG_NAME_FULL}
LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION}
LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER}
LABEL maintainer=${IMG_MAINTAINER}
ARG KAFKA_PORT
ARG KAFKA_VERSION="3.9.0"
ARG SCALA_VERSION="2.13"
ARG KAFKA_DOWNLOAD_URL="https://downloads.apache.org/kafka/${KAFKA_VERSION}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz"
ARG KAFKA_HOME="/opt/appl/kafka"
ARG KAFKA_CONFIG="${KAFKA_HOME}/config/kraft/reconfig-server.properties"
ARG KAFKA_LIB=/var/lib/kafka
ARG KAFKA_LOG=/var/log/kafka
#---------------------------------------------------------------------------------------------------
ARG KAFKAD='#!/bin/bash \n\
\n\
usermod -u ${KAFKA_UID} kafka \n\
groupmod -g ${KAFKA_GID} kafka \n\
\n\
if [[ ! -f "'${KAFKA_LIB}'/meta.properties" ]] \n\
then \n\
cd '${KAFKA_HOME}' \n\
\n\
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)" \n\
bin/kafka-storage.sh format --standalone -t "${KAFKA_CLUSTER_ID}" -c '${KAFKA_CONFIG}' \n\
fi \n\
\n\
chown -R kafka:kafka '${KAFKA_HOME}' '${KAFKA_LIB}' '${KAFKA_LOG}
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
ARG KAFKAD_INI='[program:kafkad] \n\
directory='${KAFKA_HOME}' \n\
command='${KAFKA_HOME}'/bin/kafka-server-start.sh config/kraft/reconfig-server.properties \n\
user=kafka'
#---------------------------------------------------------------------------------------------------
RUN urpmi --force wget \
&& useradd -M --home-dir ${KAFKA_HOME} --password "" kafka \
&& mkdir -p $( dirname ${KAFKA_HOME}) \
&& wget -q -O- ${KAFKA_DOWNLOAD_URL} | tar xzf - -C $( dirname ${KAFKA_HOME}) \
&& mv ${KAFKA_HOME}* ${KAFKA_HOME} \
&& sed -i "s%^advertised.listeners=%#advertised.listeners=%" ${KAFKA_CONFIG} \
&& sed -i "s%^log.dirs=/tmp/kraft-combined-logs%log.dirs=${KAFKA_LIB}%" ${KAFKA_CONFIG} \
&& ln -s ${KAFKA_LOG} ${KAFKA_HOME}/logs \
&& echo -e "${KAFKAD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/kafkad \
&& chmod a+x /etc/init.d/kafkad \
&& ln -s /etc/init.d/kafkad /etc/rcD.d/S30kafkad \
&& echo -e "${KAFKAD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/kafkad.ini
EXPOSE ${KAFKA_PORT}