From daa2948e2129fad735d6a7cbb99f141816bc156a Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 23 Jan 2018 13:39:50 +0100 Subject: [PATCH] Dockerize ActiveMQ --- activemq.sh | 15 +++++++++++++++ activemq/Dockerfile | 33 +++++++++++++++++++++++++++++++++ activemq/etc/init.d/activemq | 16 ++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100755 activemq.sh create mode 100644 activemq/Dockerfile create mode 100755 activemq/etc/init.d/activemq diff --git a/activemq.sh b/activemq.sh new file mode 100755 index 0000000..7b7e501 --- /dev/null +++ b/activemq.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/activemq + +# Build Docker container +docker build -t activemq ${SOURCE_DIR} + +# Configure ActiveMQ +mkdir -p /srv/activemq/data +chown -R 61616:61616 /srv/activemq/data + +# Configure Solr service +cp ${SOURCE_DIR}/etc/init.d/activemq /etc/init.d/activemq +rc-update add activemq boot +service activemq start diff --git a/activemq/Dockerfile b/activemq/Dockerfile new file mode 100644 index 0000000..2fc6b6d --- /dev/null +++ b/activemq/Dockerfile @@ -0,0 +1,33 @@ +FROM alpine:3.7 +MAINTAINER Disassembler + +RUN \ + # Install Java 1.8 JRE + apk --no-cache add openjdk8-jre-base paxctl \ + # Fix grsec attributes to loosen memory protection restrictions + && paxctl -cm /usr/lib/jvm/java-1.8-openjdk/jre/bin/java \ + && paxctl -cm /usr/lib/jvm/java-1.8-openjdk/bin/java \ + # Cleanup + && apk del paxctl + +RUN \ + # Download and install ActiveMQ + wget http://archive.apache.org/dist/activemq/5.15.2/apache-activemq-5.15.2-bin.tar.gz -O /tmp/activemq.tgz \ + && tar xf /tmp/activemq.tgz -C /srv \ + && mv /srv/apache-activemq-5.15.2 /srv/activemq \ + && rm -f /tmp/activemq.tgz \ + # Create OS user + && addgroup -S -g 61616 activemq \ + && adduser -S -u 61616 -h /srv/activemq -s /bin/false -g activemq -G activemq activemq \ + && mkdir /srv/activemq/tmp \ + && chown activemq:activemq /srv/activemq/tmp \ + # Configure Java heap size + && sed -i "s/-Xms64M -Xmx1G/-Xms32M -Xmx256M/" /srv/activemq/bin/env \ + # Make start/stop script visible globally + && ln -s /srv/activemq/bin/activemq /usr/local/bin/activemq + +VOLUME ["/srv/activemq/data"] +EXPOSE 61616 + +USER activemq +CMD ["activemq", "console"] diff --git a/activemq/etc/init.d/activemq b/activemq/etc/init.d/activemq new file mode 100755 index 0000000..ed6983d --- /dev/null +++ b/activemq/etc/init.d/activemq @@ -0,0 +1,16 @@ +#!/sbin/openrc-run + +description="ActiveMQ docker container" + +depend() { + need docker net + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm --name activemq -h activemq -v /srv/activemq/data:/srv/activemq/data activemq +} + +stop() { + /usr/bin/docker stop activemq +}