2024-11-24 12:48:40 +01:00
|
|
|
# Rx3-Docker/Kafka Dockerfile
|
2024-11-18 18:55:40 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-11-24 12:48:40 +01:00
|
|
|
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"
|
2024-11-18 18:55:40 +01:00
|
|
|
|
2024-11-24 12:48:40 +01:00
|
|
|
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
|
2024-11-18 18:55:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
ARG KAFKAD='#!/bin/bash \n\
|
|
|
|
\n\
|
|
|
|
usermod -u ${KAFKA_UID} kafka \n\
|
|
|
|
groupmod -g ${KAFKA_GID} kafka \n\
|
|
|
|
\n\
|
2024-11-24 12:48:40 +01:00
|
|
|
if [[ ! -f "'${KAFKA_LIB}'/meta.properties" ]] \n\
|
|
|
|
then \n\
|
|
|
|
cd '${KAFKA_HOME}' \n\
|
2024-11-18 18:55:40 +01:00
|
|
|
\n\
|
2024-11-24 12:48:40 +01:00
|
|
|
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\
|
2024-11-18 18:55:40 +01:00
|
|
|
\n\
|
2024-11-24 12:48:40 +01:00
|
|
|
chown -R kafka:kafka '${KAFKA_HOME}' '${KAFKA_LIB}' '${KAFKA_LOG}
|
2024-11-18 18:55:40 +01:00
|
|
|
#---------------------------------------------------------------------------------------------------
|
2024-11-24 12:48:40 +01:00
|
|
|
|
2024-11-18 18:55:40 +01:00
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
ARG KAFKAD_INI='[program:kafkad] \n\
|
|
|
|
directory='${KAFKA_HOME}' \n\
|
2024-11-24 12:48:40 +01:00
|
|
|
command='${KAFKA_HOME}'/bin/kafka-server-start.sh config/kraft/reconfig-server.properties \n\
|
|
|
|
user=kafka'
|
2024-11-18 18:55:40 +01:00
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-24 12:48:40 +01:00
|
|
|
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} \
|
2024-11-24 20:24:28 +01:00
|
|
|
&& sed -i "s%^advertised.listeners=%#advertised.listeners=%" ${KAFKA_CONFIG} \
|
|
|
|
&& sed -i "s%^log.dirs=/tmp/kraft-combined-logs%log.dirs=${KAFKA_LIB}%" ${KAFKA_CONFIG} \
|
2024-11-24 12:48:40 +01:00
|
|
|
&& 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
|
2024-11-18 18:55:40 +01:00
|
|
|
|
|
|
|
EXPOSE ${KAFKA_PORT}
|