- Fix kafka user & group,
- Fix LIB & LOG dirsectories, - Fix health check.
This commit is contained in:
parent
e85a67d6f1
commit
9539df8d80
36
Dockerfile
36
Dockerfile
@ -1,4 +1,4 @@
|
|||||||
# RX3-Docker/Kafka Dockerfile
|
# Rx3-Docker/Kafka Dockerfile
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
ARG IMG_FROM_URL="rx3-docker/java:latest"
|
ARG IMG_FROM_URL="rx3-docker/java:latest"
|
||||||
@ -17,8 +17,14 @@ LABEL maintainer=${IMG_MAINTAINER}
|
|||||||
|
|
||||||
ARG KAFKA_PORT
|
ARG KAFKA_PORT
|
||||||
|
|
||||||
ARG KAFKA_HOME="/opt/appl/kafka"
|
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
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
@ -27,29 +33,33 @@ ARG KAFKAD='#!/bin/bash
|
|||||||
usermod -u ${KAFKA_UID} kafka \n\
|
usermod -u ${KAFKA_UID} kafka \n\
|
||||||
groupmod -g ${KAFKA_GID} kafka \n\
|
groupmod -g ${KAFKA_GID} kafka \n\
|
||||||
\n\
|
\n\
|
||||||
chown -R kafka:kafka '${KAFKA_LIB}' '${KAFKA_LOG}' \n\
|
if [[ ! -f "'${KAFKA_LIB}'/meta.properties" ]] \n\
|
||||||
|
then \n\
|
||||||
|
cd '${KAFKA_HOME}' \n\
|
||||||
\n\
|
\n\
|
||||||
cd '${KAFKA_HOME}' \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\
|
\n\
|
||||||
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)" \n\
|
chown -R kafka:kafka '${KAFKA_HOME}' '${KAFKA_LIB}' '${KAFKA_LOG}
|
||||||
bin/kafka-storage.sh format --standalone -t \$KAFKA_CLUSTER_ID -c config/kraft/reconfig-server.properties'
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
ARG KAFKAD_INI='[program:kafkad] \n\
|
ARG KAFKAD_INI='[program:kafkad] \n\
|
||||||
directory='${KAFKA_HOME}' \n\
|
directory='${KAFKA_HOME}' \n\
|
||||||
command='${KAFKA_HOME}'/bin/kafka-server-start.sh config/kraft/reconfig-server.properties'
|
command='${KAFKA_HOME}'/bin/kafka-server-start.sh config/kraft/reconfig-server.properties \n\
|
||||||
|
user=kafka'
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN urpmi --force wget \
|
RUN urpmi --force wget \
|
||||||
&& wget -q -O /tmp/kafka.tgz https://downloads.apache.org/kafka/3.9.0/kafka_2.13-3.9.0.tgz \
|
&& useradd -M --home-dir ${KAFKA_HOME} --password "" kafka \
|
||||||
&& mkdir -p /opt/appl \
|
&& mkdir -p $( dirname ${KAFKA_HOME}) \
|
||||||
&& cd /opt/appl \
|
&& wget -q -O- ${KAFKA_DOWNLOAD_URL} | tar xzf - -C $( dirname ${KAFKA_HOME}) \
|
||||||
&& tar xf /tmp/kafka.tgz \
|
&& mv ${KAFKA_HOME}* ${KAFKA_HOME} \
|
||||||
&& mv kafka* kafka \
|
&& sed -i "s%^log.dirs=/tmp/kraft-combined-logs%log.dirs=${KAFKA_LIB}%" ${KAFKA_CONFIG} \
|
||||||
&& rm /tmp/kafka.tgz \
|
&& ln -s ${KAFKA_LOG} ${KAFKA_HOME}/logs \
|
||||||
&& echo -e "${KAFKAD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/kafkad \
|
&& echo -e "${KAFKAD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/kafkad \
|
||||||
&& chmod a+x /etc/init.d/kafkad \
|
&& chmod a+x /etc/init.d/kafkad \
|
||||||
&& ln -s /etc/init.d/kafkad /etc/rcD.d/S30kafkad \
|
&& ln -s /etc/init.d/kafkad /etc/rcD.d/S30kafkad \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
Rx3-Docker/Kafka V 1.0.0 - A. GIBERT - 2024/11/xx
|
Rx3-Docker/Kafka V 1.0.0 - A. GIBERT - 2024/11/24
|
||||||
------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
- Initial release,
|
- Initial release,
|
||||||
|
40
compose.yaml
40
compose.yaml
@ -1,4 +1,4 @@
|
|||||||
# Rx3 Proto Docker Image
|
# Rx3-Docker/Kafka Docker Image
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
name: ${HOST_NAME_PREFIX}
|
name: ${HOST_NAME_PREFIX}
|
||||||
@ -7,30 +7,30 @@ services:
|
|||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
kafka:
|
topic-server:
|
||||||
container_name: ${KAFKA_HOST_NAME}
|
container_name: ${TS_HOST_NAME}
|
||||||
hostname: ${KAFKA_HOST_NAME}
|
hostname: ${TS_HOST_NAME}
|
||||||
|
|
||||||
image: ${KAFKA_IMG_URL}
|
image: ${TS_IMG_URL}
|
||||||
|
|
||||||
build:
|
build:
|
||||||
args:
|
args:
|
||||||
IMG_NAME: ${KAFKA_IMG_URL}
|
IMG_NAME: ${TS_IMG_URL}
|
||||||
IMG_NAME_FULL: ${KAFKA_IMG_NAME_FULL}
|
IMG_NAME_FULL: ${TS_IMG_NAME_FULL}
|
||||||
IMG_VERSION: ${KAFKA_IMG_VERSION}
|
IMG_VERSION: ${TS_IMG_VERSION}
|
||||||
IMG_MAINTAINER: ${KAFKA_IMG_MAINTAINER}
|
IMG_MAINTAINER: ${TS_IMG_MAINTAINER}
|
||||||
IMG_FROM_URL: ${KAFKA_IMG_FROM_URL}
|
IMG_FROM_URL: ${TS_IMG_FROM_URL}
|
||||||
|
|
||||||
KAFKA_PORT: ${KAFKA_PORT_MAIN_INT}
|
KAFKA_PORT: ${TS_PORT_MAIN_INT}
|
||||||
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
KAFKA_UID: ${KAFKA_USER_ID}
|
KAFKA_UID: ${TS_USER_ID}
|
||||||
KAFKA_GID: ${KAFKA_GROUP_ID}
|
KAFKA_GID: ${TS_GROUP_ID}
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:${KAFKA_PORT_MAIN_INT}"]
|
test: /opt/appl/kafka/bin/kafka-cluster.sh cluster-id --bootstrap-server localhost:${TS_PORT_MAIN_INT}
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
start_period: 60s
|
start_period: 60s
|
||||||
@ -38,11 +38,11 @@ services:
|
|||||||
retries: 30
|
retries: 30
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./${KAFKA_LIB_EXT}:${KAFKA_LIB_INT}
|
- ./${TS_LIB_EXT}:${TS_LIB_INT}
|
||||||
- ./${KAFKA_LOG_INIT_EXT}:${KAFKA_LOG_INIT_INT}
|
- ./${TS_LOG_INIT_EXT}:${TS_LOG_INIT_INT}
|
||||||
- ./${KAFKA_LOG_SV_EXT}:${KAFKA_LOG_SV_INT}
|
- ./${TS_LOG_SV_EXT}:${TS_LOG_SV_INT}
|
||||||
- ./${KAFKA_LOG_MAIN_EXT}:${KAFKA_LOG_MAIN_INT}
|
- ./${TS_LOG_MAIN_EXT}:${TS_LOG_MAIN_INT}
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:${KAFKA_PORT_SV_EXT}:${KAFKA_PORT_SV_INT}"
|
- "127.0.0.1:${TS_PORT_SV_EXT}:${TS_PORT_SV_INT}"
|
||||||
- "127.0.0.1:${KAFKA_PORT_MAIN_EXT}:${KAFKA_PORT_MAIN_INT}"
|
- "127.0.0.1:${TS_PORT_MAIN_EXT}:${TS_PORT_MAIN_INT}"
|
||||||
|
13
env.dist
13
env.dist
@ -20,15 +20,18 @@ ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}"
|
|||||||
HOST_NAME_PREFIX=""
|
HOST_NAME_PREFIX=""
|
||||||
|
|
||||||
PORT_ENV_OFFSET=0
|
PORT_ENV_OFFSET=0
|
||||||
|
|
||||||
|
PORT_SV_INT=9001
|
||||||
PORT_SV_OFFSET=1000
|
PORT_SV_OFFSET=1000
|
||||||
|
|
||||||
|
|
||||||
#------------------+----------+--------------------+--------------------------+------------------------------------------+------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+
|
|
||||||
# | Variable | Target Image | From Image | Module | Main Port | Admin Port | User | Group |
|
|
||||||
# | Prefix | URL Prefix | Name | Name Full + Version | URL Prefix | Name + Version | Name | Version | Ext | Int | Ext | Int | Name / Id | Name / Id |
|
|
||||||
#------------------+----------+--------------------+--------------------------+------------------------------------------+------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+
|
|
||||||
|
|
||||||
docker_service_add KAFKA ${ORG_URL_PREFIX} kafka "Rx3-Docker/Kafka Docker Image" 1.0.0-mga9 ${ORG_URL_PREFIX} java 1.1.0-mga9 - - 9092 9092 - - apache apache
|
#------------------+----------+--------------------------+--------------------+------------------+-------------------------------+-----------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+
|
||||||
|
# | Variable | Service | Target Image | From Image | Module | Main Port | Admin Port | User | Group |
|
||||||
|
# | Prefix | Name | URL Prefix | Name | Name Full | Version | URL Prefix | Name | Version | Name | Version | Ext | Int | Ext | Int | Name / Id | Name / Id |
|
||||||
|
#------------------+----------+--------------------------+--------------------+------------------+-------------------------------+-----------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+
|
||||||
|
|
||||||
|
docker_service_add TS topic-server ${ORG_URL_PREFIX} kafka "Rx3-Docker/Kafka" 1.0.0-mga9 ${ORG_URL_PREFIX} java 1.1.0-mga9 - - 9092 9092 - - apache apache
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user