From b5f1da16ed244e1888d0a7a627b4f30352951bfd Mon Sep 17 00:00:00 2001 From: Ethan Kromhout <ethan@unc.edu> Date: Thu, 6 Sep 2018 13:12:24 -0400 Subject: [PATCH] Proposed wrapper container for review --- Dockerfile | 36 +++------------------ README.md | 14 +++----- container_files/usr-local-bin/entrypoint.sh | 5 +++ container_files/usr-local-bin/library.sh | 24 ++++++++++++++ 4 files changed, 39 insertions(+), 40 deletions(-) create mode 100755 container_files/usr-local-bin/entrypoint.sh create mode 100755 container_files/usr-local-bin/library.sh diff --git a/Dockerfile b/Dockerfile index fc6fce3..e0f1fc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,6 @@ -FROM centos:centos7 +FROM rabbitmq:3.7-management MAINTAINER ethan@unc.edu ekromhout@gmail.com -RUN yum -y install epel-release && yum -y update && yum -y install pwgen rabbitmq-server supervisor wget -ENV RABBITMQ_LOGS=- RABBITMQ_SASL_LOGS=- -RUN /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management -RUN /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_tracing -RUN sed -i s/'%% {load_definitions, .*"},'/'{load_definitions, "\/etc\/rabbitmq\/rabbitmq.json"}'/ /etc/rabbitmq/rabbitmq.config -# Installing Zulu Java -RUN rpm --import http://repos.azulsystems.com/RPM-GPG-KEY-azulsystems \ - && curl -o /etc/yum.repos.d/zulu.repo http://repos.azulsystems.com/rhel/zulu.repo \ - && yum -y install zulu-8 -#ENV JAVA_VERSION=8u171 -#ENV BUILD_VERSION=b11 -#ENV JAVA_BUNDLE_ID=512cd62ec5174c3487ac17c61aaa89e8 -# ==> By uncommenting these next 6 lines, you agree to the Oracle Binary Code License Agreement for Java SE (http://www.oracle.com/technetwork/java/javase/terms/license/index.html) -#RUN wget -nv --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/$JAVA_BUNDLE_ID/jdk-$JAVA_VERSION-linux-x64.rpm" -O /tmp/jdk-$JAVA_VERSION-$BUILD_VERSION-linux-x64.rpm && \ -# yum -y install /tmp/jdk-$JAVA_VERSION-$BUILD_VERSION-linux-x64.rpm && \ -# rm -f /tmp/jdk-$JAVA_VERSION-$BUILD_VERSION-linux-x64.rpm && \ -# alternatives --install /usr/bin/java jar $JAVA_HOME/bin/java 200000 && \ -# alternatives --install /usr/bin/javaws javaws $JAVA_HOME/bin/javaws 200000 && \ -# alternatives --install /usr/bin/javac javac $JAVA_HOME/bin/javac 200000 - -RUN sed -i s/'nodaemon=false'/'nodaemon=true'/ /etc/supervisord.conf -COPY rabbitmqctl.sh /root/ -COPY rabbittrace-0.1-jar-with-dependencies.jar /root/ -COPY trace.ini /etc/supervisord.d/ -COPY rabbitmq.ini /etc/supervisord.d/ -COPY rabbitmqctl.ini /etc/supervisord.d/ -COPY rabbitmq.json /etc/rabbitmq/ -COPY rabbittrace-0.1-jar-with-dependencies.jar /root/ -EXPOSE 5672 15672 4369 25672 -CMD ["supervisord","-c","/etc/supervisord.conf"] +ENV RABBITMQ_LOGS=/tmp/lograbbitmq RABBITMQ_SASL_LOGS=/tmp/lograbbitmq +COPY container_files/usr-local-bin/ /usr/local/bin/ +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +CMD ["rabbitmq-server"] diff --git a/README.md b/README.md index 17a3b32..55d1b36 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ -# rabbitmq-docker +# rabbitmq -This container has rabbitmq built on centos latest -and has a Java based trace class that uses rabbitmq -firehose tracing to write message traces to -/var/log/rabbitmq/trace.log as well as to stdout. - -Supervisor is used to start rabbitmq-server and Java -for the trace class, as well as to turn on rabbitmq -tracing. +This is a wrapper container for the mainstream +rabbitmq-management container. It adds logging +in the TIER format including the ENV and USERTOKEN +environment variables. Ethan Kromhout ethan@kromhout.us ethan@unc.edu diff --git a/container_files/usr-local-bin/entrypoint.sh b/container_files/usr-local-bin/entrypoint.sh new file mode 100755 index 0000000..1f62b55 --- /dev/null +++ b/container_files/usr-local-bin/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +. /usr/local/bin/library.sh +prepConf +exec "$@" diff --git a/container_files/usr-local-bin/library.sh b/container_files/usr-local-bin/library.sh new file mode 100755 index 0000000..dd4ef97 --- /dev/null +++ b/container_files/usr-local-bin/library.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +setupPipe() { + if [ -e $1 ]; then + rm $1 + fi + mkfifo -m 666 $1 +} + +setupLoggingPipe() { + # Make a "console" logging pipe that anyone can write too regardless of who owns the process. + setupPipe /tmp/logpipe + cat <> /tmp/logpipe & +} + +# Make a formatted stream to the logging pipe from rabbitmq +setupRabbitmqLog() { + (tail -F /tmp/lograbbitmq | sed -u -r "s/^/rabbitmq\;console\;$ENV\;$USERTOKEN\;/" > /tmp/logpipe) & +} + +prepConf() { + setupLoggingPipe + setupRabbitmqLog +}