- Add a post init stage to download & install rabbitmqadmin utilitiy,

- Add hostname in compose file to fix rabbitmq persistance.
This commit is contained in:
Arnaud G. GIBERT 2024-11-01 17:45:10 +01:00
parent d04d7ed47f
commit e8816edeee
4 changed files with 65 additions and 15 deletions

View File

@ -17,21 +17,58 @@ LABEL maintainer=${IMG_MAINTAINER}
ARG RABBITMQ_LIB=/var/lib/rabbitmq
ARG RABBITMQ_PORT=5672
ARG RABBITMQ_ADMIN_PORT=15672
#---------------------------------------------------------------------------------------------------
ARG RABBITMQD='#!/bin/bash \n\
\n\
usermod -u ${RABBITMQ_UID} -s /bin/bash rabbitmq \n\
groupmod -g ${RABBITMQ_GID} rabbitmq \n\
\n\
#-------------------------------------------------------------------------------------------------------------------
ARG RABBITMQD='#!/bin/bash \n\
\n\
usermod -u ${RABBITMQ_UID} -s /bin/bash rabbitmq \n\
groupmod -g ${RABBITMQ_GID} rabbitmq \n\
\n\
chown -R rabbitmq:rabbitmq '${RABBITMQ_LIB}' /var/log/rabbitmq /var/run/rabbitmq'
#---------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
ARG RABBITMQD_INI='[program:rabbitmqd] \n\
command=su - rabbitmq -c /usr/lib/rabbitmq/bin/rabbitmq-server \n\
#-------------------------------------------------------------------------------------------------------------------
ARG RABBITMQD_INI='[program:rabbitmqd] \n\
command=su - rabbitmq -c /usr/lib/rabbitmq/bin/rabbitmq-server \n\
user=root'
#---------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------
ARG POSTRMQ='#!/bin/bash \n\
\n\
function log() { echo "$(date --rfc-3339=ns) PostRMQ: $*" | tee -a /var/log/postrmq.log; } \n\
\n\
log "Starting" \n\
\n\
for i in {30..0} \n\
do \n\
if curl http://127.0.0.1:'${RABBITMQ_ADMIN_PORT}'/cli/rabbitmqadmin &> /dev/null \n\
then \n\
break \n\
fi \n\
\n\
sleep 1 \n\
done \n\
\n\
if [ "$i" = 0 ] \n\
then \n\
log "Unable to connect to server" \n\
else \n\
log "Downloading rabbitmqadmin" \n\
curl -o /usr/local/bin/rabbitmqadmin http://127.0.0.1:'${RABBITMQ_ADMIN_PORT}'/cli/rabbitmqadmin &>/dev/null \n\
\n\
chmod a+rx /usr/local/bin/rabbitmqadmin \n\
fi \n\
\n\
log "Completed"'
#-------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------
ARG POSTRMQ_INI='[program:postrmq] \n\
command=/usr/local/sbin/postrmq'
#-------------------------------------------------------------------------------------------------------------------
@ -41,11 +78,14 @@ RUN urpmi --force lksctp-tools \
&& echo -e "${RABBITMQD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/rabbitmqd \
&& chmod a+x /etc/init.d/rabbitmqd \
&& ln -s /etc/init.d/rabbitmqd /etc/rcD.d/S40rabbitmqd \
&& echo -e "${RABBITMQD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/rabbitmqd.ini
&& echo -e "${RABBITMQD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/rabbitmqd.ini \
&& echo -e "${POSTRMQ}" | sed -e "s/\`/'/g" -e 's/ *$//' > /usr/local/sbin/postrmq \
&& chmod a+x /usr/local/sbin/postrmq \
&& echo -e "${POSTRMQ_INI}" | sed -e 's/ *$//' > /etc/supervisord.d/postrmq.ini
VOLUME ${RABBITMQ_LIB}
EXPOSE 5672
EXPOSE 15672
EXPOSE ${RABBITMQ_ADMIN_PORT}
EXPOSE ${RABBITMQ_ADMIN_PORT}

View File

@ -1,3 +1,12 @@
------------------------------------------------------------------------------------------------------------------------------------
Rx3/RabbitMQ-Mga9 V 1.0.2 - A. GIBERT - 2024/11/01
------------------------------------------------------------------------------------------------------------------------------------
- Add a post init stage to download & install rabbitmqadmin utilitiy,
- Add hostname in compose file to fix rabbitmq persistance.
------------------------------------------------------------------------------------------------------------------------------------
Rx3/RabbitMQ-Mga9 V 1.0.1 - A. GIBERT - 2024/10/07
------------------------------------------------------------------------------------------------------------------------------------

View File

@ -7,6 +7,7 @@ services:
mqserver:
container_name: ${IMG_NAME}
hostname: ${IMG_NAME}
image: ${IMG_URL}

2
env
View File

@ -17,7 +17,7 @@ IMG_URL_PREFIX="${IMG_REGISTRY}/${IMG_ORG}"
IMG_NAME="rabbitmq-mga9"
IMG_FULL_NAME="Rx3 RabbitMQ Mageia-9 Docker Image"
IMG_VERSION="1.0.1"
IMG_VERSION="1.0.2"
IMG_URL="${IMG_URL_PREFIX}/${IMG_NAME}:${IMG_VERSION}"
IMG_MAINTAINER='"Arnaud G. GIBERT" <arnaud@rx3.net>'