From 770c6fbd8e6eaf2451d42fd40db55bda65375de6 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Thu, 11 Jan 2018 16:36:57 +0100 Subject: [PATCH] Add RabbitMQ Dockerfile + script --- rabbitmq.sh | 15 +++++++++++++++ rabbitmq/Dockerfile | 17 +++++++++++++++++ rabbitmq/etc/init.d/rabbitmq | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100755 rabbitmq.sh create mode 100644 rabbitmq/Dockerfile create mode 100755 rabbitmq/etc/init.d/rabbitmq diff --git a/rabbitmq.sh b/rabbitmq.sh new file mode 100755 index 0000000..6b7f3cc --- /dev/null +++ b/rabbitmq.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/rabbitmq + +# Build Docker container +docker build -t rabbitmq ${SOURCE_DIR} + +# Create RabbitMQ directory structure +mkdir -p /srv/rabbitmq/data +chown 5672:5672 /srv/rabbitmq/data + +# Configure RabbitMQ service +cp ${SOURCE_DIR}/etc/init.d/rabbitmq /etc/init.d/rabbitmq +rc-update add rabbitmq boot +service rabbitmq start diff --git a/rabbitmq/Dockerfile b/rabbitmq/Dockerfile new file mode 100644 index 0000000..8074d60 --- /dev/null +++ b/rabbitmq/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:3.7 +MAINTAINER Disassembler + +RUN \ + # Create OS user (which will be picked up later by apk add) + addgroup -S -g 5672 rabbitmq \ + && adduser -S -u 5672 -h /usr/lib/rabbitmq -s /sbin/nologin -g rabbitmq -G rabbitmq rabbitmq \ + # Add edge/testing repository + && echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories \ + # Install RabbitMQ + && apk --no-cache add rabbitmq-server + +VOLUME ["/var/lib/rabbitmq/mnesia"] +EXPOSE 5672 + +USER rabbitmq +CMD ["rabbitmq-server"] diff --git a/rabbitmq/etc/init.d/rabbitmq b/rabbitmq/etc/init.d/rabbitmq new file mode 100755 index 0000000..14994c1 --- /dev/null +++ b/rabbitmq/etc/init.d/rabbitmq @@ -0,0 +1,16 @@ +#!/sbin/openrc-run + +description="RabbitMQ docker container" + +depend() { + need docker net + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm --name rabbitmq -v /srv/rabbitmq/data:/var/lib/rabbitmq/mnesia rabbitmq +} + +stop() { + /usr/bin/docker stop rabbitmq +}