diff --git a/README.md b/README.md index 3078fff..07bf520 100644 --- a/README.md +++ b/README.md @@ -7,56 +7,9 @@ There are 3 folders. 1. base - the base Dockerfile is based on an Ubuntu image with RabbitMQ installations. 2. server - This builds on the base image and has the startup script for bring up a RabbitMQ server -4. cluster - This contains a https://docs.docker.com/compose/[docker-compose] definition file(docker-compose.yml) for brining up the rabbitmq cluster. Use `docker-compose up -d` to bring up the cluster. +4. cluster - This contains a https://docs.docker.com/compose/[docker-compose] definition file(docker-compose.yml) for brining up the rabbitmq cluster. Use `docker-compose -f docker-compose.yml up` to bring up the cluster. - -Running the Cluster: -=============================== -Once the images are built, boot up the cluster using the docker-compose.yml configuration provided in cluster folder: - -[source] ----- -docker-compose up -d ----- - -By default 3 nodes are started up this way: - -[source] ----- -rabbit1: - image: relaxart/rabbitmq-server - hostname: rabbit1 - ports: - - "5672:5672" - - "15672:15672" - -rabbit2: - image: relaxart/rabbitmq-server - hostname: rabbit2 - links: - - rabbit1 - environment: - - CLUSTERED=true - - CLUSTER_WITH=rabbit1 - - RAM_NODE=true - ports: - - "5673:5672" - - "15673:15672" - -rabbit3: - image: relaxart/rabbitmq-server - hostname: rabbit3 - links: - - rabbit1 - - rabbit2 - environment: - - CLUSTERED=true - - CLUSTER_WITH=rabbit1 - ports: - - "5674:5672" ----- - -if needed, additional nodes can be added to this file. If the entire cluster comes up, the management console can be accessed at http://:15672 +If needed, additional nodes can be added to this file. If the entire cluster comes up, the management console can be accessed at http://:15672 and connection host should look like this: `dockerip:5672,dockerip:5673,dockerip:5674` \ No newline at end of file diff --git a/base/Dockerfile b/base/Dockerfile deleted file mode 100644 index ad3b7c4..0000000 --- a/base/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu -MAINTAINER Ilya Isaev me@ilyaisaev.com - -RUN apt-get update && \ - apt-get install -y wget && \ - echo "deb http://www.rabbitmq.com/debian/ testing main" | tee /etc/apt/sources.list.d/rabbitmq.list && \ - wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add - && \ - apt-get update && \ - apt-get install -y rabbitmq-server && \ - /usr/sbin/rabbitmq-plugins enable --offline rabbitmq_management rabbitmq_management_agent rabbitmq_management_visualiser rabbitmq_federation rabbitmq_federation_management \ No newline at end of file diff --git a/cluster/docker-compose.yml b/docker-compose.yml similarity index 72% rename from cluster/docker-compose.yml rename to docker-compose.yml index 8fbc97a..3b11194 100644 --- a/cluster/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,14 @@ rabbit1: - image: relaxart/rabbitmq-server +# image: relaxart/rabbitmq-server + build: ./server hostname: rabbit1 ports: - "5672:5672" - "15672:15672" rabbit2: - image: relaxart/rabbitmq-server +# image: relaxart/rabbitmq-server + build: ./server hostname: rabbit2 links: - rabbit1 @@ -19,7 +21,8 @@ rabbit2: - "15673:15672" rabbit3: - image: relaxart/rabbitmq-server +# image: relaxart/rabbitmq-server + build: ./server hostname: rabbit3 links: - rabbit1 diff --git a/server/Dockerfile b/server/Dockerfile index 188b1c5..3df12fe 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,9 +1,21 @@ -FROM relaxart/rabbitmq-base -MAINTAINER Ilya Isaev me@ilyaisaev.com +FROM ubuntu + +RUN apt-get update && \ + apt-get install -y wget && \ + echo "deb http://www.rabbitmq.com/debian/ testing main" | tee /etc/apt/sources.list.d/rabbitmq.list && \ + wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | apt-key add - && \ + apt-get update && \ + apt-get install -y rabbitmq-server && \ + /usr/sbin/rabbitmq-plugins enable --offline rabbitmq_management rabbitmq_management_agent rabbitmq_management_visualiser rabbitmq_federation rabbitmq_federation_management + +ENV DOCKERIZE_VERSION v0.2.0 ADD rabbitmq.config /etc/rabbitmq/rabbitmq.config ADD erlang.cookie /var/lib/rabbitmq/.erlang.cookie +RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz + RUN chmod u+rw /etc/rabbitmq/rabbitmq.config && \ chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie && \ chmod 400 /var/lib/rabbitmq/.erlang.cookie && \ diff --git a/server/run.sh b/server/run.sh index fac0c96..6bb81e7 100644 --- a/server/run.sh +++ b/server/run.sh @@ -1,15 +1,17 @@ #!/bin/bash if [ -z "$CLUSTERED" ]; then - # if not clustered then start it normally as if it is a single server - /usr/sbin/rabbitmq-server + /usr/sbin/rabbitmq-server -detached else if [ -z "$CLUSTER_WITH" ]; then - # If clustered, but cluster with is not specified then again start normally, could be the first server in the - # cluster - /usr/sbin/rabbitmq-server + /usr/sbin/rabbitmq-server -detached else + #clean folder with data before joining cluster + rm -rf /var/lib/rabbitmq/* + dockerize -wait tcp://$CLUSTER_WITH:25672 -timeout 250s + /usr/sbin/rabbitmq-server -detached + rabbitmqctl stop_app if [ -z "$RAM_NODE" ]; then rabbitmqctl join_cluster rabbit@$CLUSTER_WITH @@ -17,9 +19,7 @@ else rabbitmqctl join_cluster --ram rabbit@$CLUSTER_WITH fi rabbitmqctl start_app - - # Tail to keep the a foreground process active.. - tail -f /var/log/rabbitmq/rabbit\@$HOSTNAME.log fi fi - +sleep 60 && echo "Ilya we need to fix logging..." +tail -f /var/log/rabbitmq/*