From f2a2d6d99fcffccddec411fbff50c655c3ba1dd1 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 22 Oct 2018 21:11:02 -0400 Subject: [PATCH 1/4] ARTEMIS-2245 Implement Docker images --- .../activemq/artemis/cli/commands/Create.java | 10 ++ .../cli/commands/etc/jolokia-access.xml | 5 +- artemis-distribution/pom.xml | 15 ++- .../src/main/assembly/docker-assembly.xml | 40 +++++++ .../src/main/resources/docker/Dockerfile | 101 ++++++++++++++++++ .../docker/assets/docker-entrypoint.sh | 18 ++++ 6 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 artemis-distribution/src/main/assembly/docker-assembly.xml create mode 100644 artemis-distribution/src/main/resources/docker/Dockerfile create mode 100755 artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java index cde65152db..3982fac36a 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java @@ -119,6 +119,9 @@ public class Create extends InputAbstract { @Option(name = "--http-host", description = "The host name to use for embedded web server (Default: localhost)") private String httpHost = HTTP_HOST; + @Option(name = "--relax-jolokia", description = "disable strict checking on jolokia-access.xml") + private boolean relaxJolokia; + @Option(name = "--ping", description = "A comma separated string to be passed on to the broker config as network-check-list. The broker will shutdown when all these addresses are unreachable.") private String ping; @@ -774,6 +777,13 @@ public class Create extends InputAbstract { filters.remove("${artemis.instance}"); writeEtc(ETC_BOOTSTRAP_XML, etcFolder, filters, false); writeEtc(ETC_MANAGEMENT_XML, etcFolder, filters, false); + + if (relaxJolokia) { + filters.put("${jolokia.options}", ""); + } else { + filters.put("${jolokia.options}", "\n" + + " "); + } writeEtc(ETC_JOLOKIA_ACCESS_XML, etcFolder, filters, false); context.out.println(""); diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/jolokia-access.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/jolokia-access.xml index aff56567da..89aa41c0e1 100644 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/jolokia-access.xml +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/jolokia-access.xml @@ -26,8 +26,9 @@ under the License. *://${http.host}* - - + + + ${jolokia.options} \ No newline at end of file diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml index af716cc75b..2618b092b1 100644 --- a/artemis-distribution/pom.xml +++ b/artemis-distribution/pom.xml @@ -242,7 +242,7 @@ maven-assembly-plugin ${maven.assembly.plugin.version} - + source src/main/assembly/source-assembly.xml @@ -254,7 +254,7 @@ - bin + bin src/main/assembly/dep.xml gnu @@ -264,6 +264,17 @@ single + + docker + + src/main/assembly/docker-assembly.xml + gnu + + package + + single + + diff --git a/artemis-distribution/src/main/assembly/docker-assembly.xml b/artemis-distribution/src/main/assembly/docker-assembly.xml new file mode 100644 index 0000000000..054bd6b381 --- /dev/null +++ b/artemis-distribution/src/main/assembly/docker-assembly.xml @@ -0,0 +1,40 @@ + + + + + docker + + dir + + false + + + + ${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version} + /build/opt/activemq-artemis + true + + + src/main/resources/docker + /build + true + + + diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile b/artemis-distribution/src/main/resources/docker/Dockerfile new file mode 100644 index 0000000000..ae34d14bd7 --- /dev/null +++ b/artemis-distribution/src/main/resources/docker/Dockerfile @@ -0,0 +1,101 @@ +# ActiveMQ Artemis + +########################################################## +## Build Image # +########################################################## +FROM openjdk:8u171-jdk-stretch as builder +LABEL maintainer="Apache ActiveMQ Team" + +ENV JMX_EXPORTER_VERSION=0.3.1 +ENV JGROUPS_KUBERNETES_VERSION=0.9.3 + +# See https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN apt-get -qq -o=Dpkg::Use-Pty=0 update && \ + apt-get -qq -o=Dpkg::Use-Pty=0 install -y --no-install-recommends \ + libaio1=0.3.110-3 \ + xmlstarlet=1.6.1-2 \ + jq=1.5+dfsg-1.3 \ + ca-certificates=20161130+nmu1+deb9u1 \ + wget=1.18-5+deb9u2 + +# I like to be able to verify files within a docker container +RUN apt-get install -y vim +RUN apt-get install -y screen +#RUN rm -rf /var/lib/apt/lists/* + +# Make sure pipes are considered to detemine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Uncompress and validate +WORKDIR /opt + +########################################################## +## Run Image # +########################################################## +FROM openjdk:8 +LABEL maintainer="Apache ActiveMQ Team" + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV CREATE_ARGUMENTS --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent --http-host 0.0.0.0 --relax-jolokia + +# add user and group for artemis +RUN groupadd -g 1000 -r artemis && useradd -r -u 1000 -g artemis artemis + +RUN apt-get -qq -o=Dpkg::Use-Pty=0 update && \ + apt-get -qq -o=Dpkg::Use-Pty=0 install -y --no-install-recommends \ + libaio1=0.3.110-3 \ + xmlstarlet=1.6.1-2 \ + jq=1.5+dfsg-1.3 \ + gettext-base=0.19.8.1-2 \ + dumb-init=1.2.0-1 + +RUN apt-get install -y vim +RUN apt-get install -y screen + +RUN rm -rf /var/lib/apt/lists/* + +USER artemis + +COPY "/opt/activemq-artemis/" "/opt/activemq-artemis" + +# Web Server +EXPOSE 8161 + +# JMX Exporter +EXPOSE 9404 + +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE +EXPOSE 61616 + +# Port for HORNETQ,STOMP +EXPOSE 5445 + +# Port for AMQP +EXPOSE 5672 + +# Port for MQTT +EXPOSE 1883 + +#Port for STOMP +EXPOSE 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance +RUN chown -R artemis.artemis /var/lib/artemis-instance +COPY assets/docker-entrypoint.sh / + +USER artemis + + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["artemis-server"] diff --git a/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh b/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh new file mode 100755 index 0000000000..cd4c3f4e1c --- /dev/null +++ b/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +BROKER_HOME=/var/lib/ +CONFIG_PATH=$BROKER_HOME/etc +export BROKER_HOME OVERRIDE_PATH CONFIG_PATH + +echo CREATE_ARGUMENTS=${CREATE_ARGUMENTS} + +if ! [ -f ./etc/broker.xml ]; then + /opt/activemq-artemis/bin/artemis create ${CREATE_ARGUMENTS} . +else + echo "broker already created, ignoring creation" +fi + +./bin/artemis run + + From d9af3bb4800e0dbb7a551ec3752e9494158de96d Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Sat, 2 Feb 2019 09:12:17 +0100 Subject: [PATCH 2/4] ARTEMIS-2245 Cleaning and Extending Docker images Cleaning Docker images and adding CentOS version --- .../src/main/assembly/dep.xml | 1 + .../src/main/resources/docker/Dockerfile | 101 ------------------ .../main/resources/docker/Dockerfile-centos | 72 +++++++++++++ .../main/resources/docker/Dockerfile-ubuntu | 72 +++++++++++++ .../docker/assets/docker-entrypoint.sh | 17 +++ 5 files changed, 162 insertions(+), 101 deletions(-) delete mode 100644 artemis-distribution/src/main/resources/docker/Dockerfile create mode 100644 artemis-distribution/src/main/resources/docker/Dockerfile-centos create mode 100644 artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu diff --git a/artemis-distribution/src/main/assembly/dep.xml b/artemis-distribution/src/main/assembly/dep.xml index ead7396f35..bae01a5086 100644 --- a/artemis-distribution/src/main/assembly/dep.xml +++ b/artemis-distribution/src/main/assembly/dep.xml @@ -207,6 +207,7 @@ **/**/*.iml **/**/*.dat **/licenses/** + docker/** diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile b/artemis-distribution/src/main/resources/docker/Dockerfile deleted file mode 100644 index ae34d14bd7..0000000000 --- a/artemis-distribution/src/main/resources/docker/Dockerfile +++ /dev/null @@ -1,101 +0,0 @@ -# ActiveMQ Artemis - -########################################################## -## Build Image # -########################################################## -FROM openjdk:8u171-jdk-stretch as builder -LABEL maintainer="Apache ActiveMQ Team" - -ENV JMX_EXPORTER_VERSION=0.3.1 -ENV JGROUPS_KUBERNETES_VERSION=0.9.3 - -# See https://github.com/hadolint/hadolint/wiki/DL4006 -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -RUN apt-get -qq -o=Dpkg::Use-Pty=0 update && \ - apt-get -qq -o=Dpkg::Use-Pty=0 install -y --no-install-recommends \ - libaio1=0.3.110-3 \ - xmlstarlet=1.6.1-2 \ - jq=1.5+dfsg-1.3 \ - ca-certificates=20161130+nmu1+deb9u1 \ - wget=1.18-5+deb9u2 - -# I like to be able to verify files within a docker container -RUN apt-get install -y vim -RUN apt-get install -y screen -#RUN rm -rf /var/lib/apt/lists/* - -# Make sure pipes are considered to detemine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# Uncompress and validate -WORKDIR /opt - -########################################################## -## Run Image # -########################################################## -FROM openjdk:8 -LABEL maintainer="Apache ActiveMQ Team" - -ENV ARTEMIS_USER artemis -ENV ARTEMIS_PASSWORD artemis -ENV ANONYMOUS_LOGIN false -ENV CREATE_ARGUMENTS --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent --http-host 0.0.0.0 --relax-jolokia - -# add user and group for artemis -RUN groupadd -g 1000 -r artemis && useradd -r -u 1000 -g artemis artemis - -RUN apt-get -qq -o=Dpkg::Use-Pty=0 update && \ - apt-get -qq -o=Dpkg::Use-Pty=0 install -y --no-install-recommends \ - libaio1=0.3.110-3 \ - xmlstarlet=1.6.1-2 \ - jq=1.5+dfsg-1.3 \ - gettext-base=0.19.8.1-2 \ - dumb-init=1.2.0-1 - -RUN apt-get install -y vim -RUN apt-get install -y screen - -RUN rm -rf /var/lib/apt/lists/* - -USER artemis - -COPY "/opt/activemq-artemis/" "/opt/activemq-artemis" - -# Web Server -EXPOSE 8161 - -# JMX Exporter -EXPOSE 9404 - -# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE -EXPOSE 61616 - -# Port for HORNETQ,STOMP -EXPOSE 5445 - -# Port for AMQP -EXPOSE 5672 - -# Port for MQTT -EXPOSE 1883 - -#Port for STOMP -EXPOSE 61613 - -USER root - -RUN mkdir /var/lib/artemis-instance -RUN chown -R artemis.artemis /var/lib/artemis-instance -COPY assets/docker-entrypoint.sh / - -USER artemis - - -# Expose some outstanding folders -VOLUME ["/var/lib/artemis-instance"] -WORKDIR /var/lib/artemis-instance - - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["artemis-server"] diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile-centos b/artemis-distribution/src/main/resources/docker/Dockerfile-centos new file mode 100644 index 0000000000..bfcfb2dcb5 --- /dev/null +++ b/artemis-distribution/src/main/resources/docker/Dockerfile-centos @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# ActiveMQ Artemis + +FROM jboss/base-jdk:8 +LABEL maintainer="Apache ActiveMQ Team" +LABEL ARTEMIS_VERSION="2.7.0-SNAPSHOT" +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV CREATE_ARGUMENTS --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent --http-host 0.0.0.0 --relax-jolokia + +USER root + +# add user and group for artemis +RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis + +RUN yum install -y libaio && \ + yum -y clean all + +USER artemis + +COPY "/opt/activemq-artemis/" "/opt/activemq-artemis" + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY assets/docker-entrypoint.sh / + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["artemis-server"] \ No newline at end of file diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu b/artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu new file mode 100644 index 0000000000..4946e92171 --- /dev/null +++ b/artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# ActiveMQ Artemis + +FROM openjdk:8 +LABEL maintainer="Apache ActiveMQ Team" +LABEL ARTEMIS_VERSION="2.7.0-SNAPSHOT" +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV CREATE_ARGUMENTS --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent --http-host 0.0.0.0 --relax-jolokia + +# add user and group for artemis +RUN groupadd -g 1000 -r artemis && useradd -r -u 1000 -g artemis artemis + +RUN apt-get -qq -o=Dpkg::Use-Pty=0 update && \ + apt-get -qq -o=Dpkg::Use-Pty=0 install -y --no-install-recommends \ + libaio1=0.3.110-3 && \ + rm -rf /var/lib/apt/lists/* + +USER artemis + +COPY "/opt/activemq-artemis/" "/opt/activemq-artemis" + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY assets/docker-entrypoint.sh / + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["artemis-server"] \ No newline at end of file diff --git a/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh b/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh index cd4c3f4e1c..4d2385b1be 100755 --- a/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh +++ b/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh @@ -1,4 +1,21 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + set -e BROKER_HOME=/var/lib/ From 8c89c3584fbd12f6a26de9fdaabab3061c2a6f59 Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Mon, 4 Feb 2019 18:54:57 +0100 Subject: [PATCH 3/4] ARTEMIS-2245 adding Docker images User guide --- docs/user-manual/en/SUMMARY.md | 1 + docs/user-manual/en/docker.md | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 docs/user-manual/en/docker.md diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index 0aa3085155..3243b54ca5 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -72,4 +72,5 @@ * [Maven Plugin](maven-plugin.md) * [Unit Testing](unit-testing.md) * [Troubleshooting and Performance Tuning](perf-tuning.md) +* [Docker support](docker.md) * [Configuration Reference](configuration-index.md) diff --git a/docs/user-manual/en/docker.md b/docs/user-manual/en/docker.md new file mode 100644 index 0000000000..5dfcf55fdb --- /dev/null +++ b/docs/user-manual/en/docker.md @@ -0,0 +1,26 @@ +# Artemis on Docker + +Artemis provide support to build CentOS and Ubuntu images of the broker, allowing to reuse +an existing broker instance *ie from a previous image run* or just creating a fresh new one. + +## Building a CentOS image +From within the folder with both `Dockerfile-centos` file and `assets` folder: +``` +$ docker build -f Dockerfile-centos -t artemis-centos . +``` +> **Note:** +>`-t artemis-centos` is just a tag name for the purpose of this guide +## Running a CentOS image +The image just created in the previous step allows both stateless or stateful runs. +The stateless run is achieved by: +``` +$ docker run --rm -it -p 61616:61616 -p 8161:8161 artemis-centos +``` +While a stateful run with: +``` +docker run -it -p 61616:61616 -p 8161:8161 -v :/var/lib/artemis-instance artemis-centos +``` +where `` is a folder where the broker instance is supposed to +be saved and reused on each run. + + From 02505fc004aafa96708af5987137cefa0af5fa45 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 4 Feb 2019 18:49:59 -0500 Subject: [PATCH 4/4] ARTEMIS-2245 Moving docker files under artemis-docker and other improvements --- artemis-distribution/pom.xml | 11 --- .../src/main/assembly/docker-assembly.xml | 40 ---------- .../Dockerfile-centos | 7 +- .../Dockerfile-ubuntu | 7 +- .../docker-run.sh | 6 ++ artemis-docker/prepare-docker.sh | 56 ++++++++++++++ artemis-docker/readme.md | 75 +++++++++++++++++++ docs/user-manual/en/SUMMARY.md | 1 - docs/user-manual/en/docker.md | 26 ------- 9 files changed, 143 insertions(+), 86 deletions(-) delete mode 100644 artemis-distribution/src/main/assembly/docker-assembly.xml rename {artemis-distribution/src/main/resources/docker => artemis-docker}/Dockerfile-centos (92%) rename {artemis-distribution/src/main/resources/docker => artemis-docker}/Dockerfile-ubuntu (92%) rename artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh => artemis-docker/docker-run.sh (91%) create mode 100755 artemis-docker/prepare-docker.sh create mode 100644 artemis-docker/readme.md delete mode 100644 docs/user-manual/en/docker.md diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml index 2618b092b1..89b3aed853 100644 --- a/artemis-distribution/pom.xml +++ b/artemis-distribution/pom.xml @@ -264,17 +264,6 @@ single - - docker - - src/main/assembly/docker-assembly.xml - gnu - - package - - single - - diff --git a/artemis-distribution/src/main/assembly/docker-assembly.xml b/artemis-distribution/src/main/assembly/docker-assembly.xml deleted file mode 100644 index 054bd6b381..0000000000 --- a/artemis-distribution/src/main/assembly/docker-assembly.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - docker - - dir - - false - - - - ${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version} - /build/opt/activemq-artemis - true - - - src/main/resources/docker - /build - true - - - diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile-centos b/artemis-docker/Dockerfile-centos similarity index 92% rename from artemis-distribution/src/main/resources/docker/Dockerfile-centos rename to artemis-docker/Dockerfile-centos index bfcfb2dcb5..b76c8e367e 100644 --- a/artemis-distribution/src/main/resources/docker/Dockerfile-centos +++ b/artemis-docker/Dockerfile-centos @@ -19,7 +19,6 @@ FROM jboss/base-jdk:8 LABEL maintainer="Apache ActiveMQ Team" -LABEL ARTEMIS_VERSION="2.7.0-SNAPSHOT" # Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /opt @@ -39,7 +38,7 @@ RUN yum install -y libaio && \ USER artemis -COPY "/opt/activemq-artemis/" "/opt/activemq-artemis" +ADD . /opt/activemq-artemis # Web Server EXPOSE 8161 \ @@ -60,7 +59,7 @@ USER root RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance -COPY assets/docker-entrypoint.sh / +COPY ./docker/docker-run.sh / USER artemis @@ -68,5 +67,5 @@ USER artemis VOLUME ["/var/lib/artemis-instance"] WORKDIR /var/lib/artemis-instance -ENTRYPOINT ["/docker-entrypoint.sh"] +ENTRYPOINT ["/docker-run.sh"] CMD ["artemis-server"] \ No newline at end of file diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu b/artemis-docker/Dockerfile-ubuntu similarity index 92% rename from artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu rename to artemis-docker/Dockerfile-ubuntu index 4946e92171..a141cc058a 100644 --- a/artemis-distribution/src/main/resources/docker/Dockerfile-ubuntu +++ b/artemis-docker/Dockerfile-ubuntu @@ -19,7 +19,6 @@ FROM openjdk:8 LABEL maintainer="Apache ActiveMQ Team" -LABEL ARTEMIS_VERSION="2.7.0-SNAPSHOT" # Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /opt @@ -39,7 +38,7 @@ RUN apt-get -qq -o=Dpkg::Use-Pty=0 update && \ USER artemis -COPY "/opt/activemq-artemis/" "/opt/activemq-artemis" +ADD . /opt/activemq-artemis # Web Server EXPOSE 8161 \ @@ -60,7 +59,7 @@ USER root RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance -COPY assets/docker-entrypoint.sh / +COPY ./docker/docker-run.sh / USER artemis @@ -68,5 +67,5 @@ USER artemis VOLUME ["/var/lib/artemis-instance"] WORKDIR /var/lib/artemis-instance -ENTRYPOINT ["/docker-entrypoint.sh"] +ENTRYPOINT ["/docker-run.sh"] CMD ["artemis-server"] \ No newline at end of file diff --git a/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh b/artemis-docker/docker-run.sh similarity index 91% rename from artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh rename to artemis-docker/docker-run.sh index 4d2385b1be..9e7bdb451d 100755 --- a/artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh +++ b/artemis-docker/docker-run.sh @@ -16,6 +16,12 @@ # specific language governing permissions and limitations # under the License. + + +# This is the entry point for the docker images. +# This file is executed when docker run is called. + + set -e BROKER_HOME=/var/lib/ diff --git a/artemis-docker/prepare-docker.sh b/artemis-docker/prepare-docker.sh new file mode 100755 index 0000000000..7fa474a279 --- /dev/null +++ b/artemis-docker/prepare-docker.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Setting the script to fail if anything goes wrong +set -e + +#This is a script to Prepare an artemis folder to generate the Release. + + +error () { + echo "" + echo "$@" + echo "" + echo "Usage: ./prepare-docker.sh ARTEMIS_HOME_LOCATION" + echo "" + echo "example:" + echo "./prepare-release.sh https://repo1.maven.org/maven2 2.5.0" + echo "" + exit 64 +} + +if [ ! "$#" -eq 1 ] +then + error "Cannot match arguments" +fi + +target=$1 + +if [ ! -d $target ] +then + error "Directory $target does not exist" +fi + +if [ -d $target/docker ] +then + rm -rf $target/docker +fi +mkdir $target/docker +cp * $target/docker + +echo "Docker file support files at : $target/docker" diff --git a/artemis-docker/readme.md b/artemis-docker/readme.md new file mode 100644 index 0000000000..055e4be23a --- /dev/null +++ b/artemis-docker/readme.md @@ -0,0 +1,75 @@ +# Docker Image Example * + +This is an example on how you could create your own Docker Image For Apache ActiveMQ Artemis based on CentOS or Ubuntu. +# Preparing + +Use the script ./prepare-docker.sh as it will copy the docker files under the binary distribution. + +``` +$ ./prepare.sh $ARTEMIS_HOME +``` + +# Building + +Go to $ARTEMIS_HOME where you prepared the binary with Docker files. + +## For Ubuntu: + +From within the $ARTEMIS_HOME +``` +$ docker build -f ./docker/Dockerfile-ubuntu -t artemis-ubuntu . +``` + +**Note:** +-t artemis-ubuntu` is just a tag name for the purpose of this guide + +## For CentOS + +From within the binary distribution folder: +``` +$ docker build -f ./docker/Dockerfile-centos -t artemis-centos . +``` + +# Variables: + + - ARTEMIS_USER + - ARTEMIS_PASSWORD + - ANONYMOUS_LOGIN + +Default here is FALSE. If you set this to true, it will change security settings passed on the broker instance creation. + +- CREATE_ARGUMENTS + +Default here is " --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent --http-host 0.0.0.0 --relax-jolokia" + + +This will be passed straight to ./artemis create during the execution. + + +# Mapping point + +- /var/lib/artemis-instance + +It's possible to map a folder as the instance broker. +This will hold the configuration and the data of the running broker. This is useful for when you want the data persisted outside of a container. + + +# Lifecycle of the execution + +A broker instance will be created during the execution of the instance. If you pass a mapped folder for /var/lib/artemis-instance an image will be created or reused depending on the contents of the folder. + + + +## Running a CentOS image + +The image just created in the previous step allows both stateless or stateful runs. +The stateless run is achieved by: +``` +$ docker run --rm -it -p 61616:61616 -p 8161:8161 artemis-centos +``` +The image will also support mapped folders and mapped ports. To run the image with the instance persisted on the host: +``` +docker run -it -p 61616:61616 -p 8161:8161 -v :/var/lib/artemis-instance artemis-centos +``` +where `` is a folder where the broker instance is supposed to +be saved and reused on each run. diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index 3243b54ca5..0aa3085155 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -72,5 +72,4 @@ * [Maven Plugin](maven-plugin.md) * [Unit Testing](unit-testing.md) * [Troubleshooting and Performance Tuning](perf-tuning.md) -* [Docker support](docker.md) * [Configuration Reference](configuration-index.md) diff --git a/docs/user-manual/en/docker.md b/docs/user-manual/en/docker.md deleted file mode 100644 index 5dfcf55fdb..0000000000 --- a/docs/user-manual/en/docker.md +++ /dev/null @@ -1,26 +0,0 @@ -# Artemis on Docker - -Artemis provide support to build CentOS and Ubuntu images of the broker, allowing to reuse -an existing broker instance *ie from a previous image run* or just creating a fresh new one. - -## Building a CentOS image -From within the folder with both `Dockerfile-centos` file and `assets` folder: -``` -$ docker build -f Dockerfile-centos -t artemis-centos . -``` -> **Note:** ->`-t artemis-centos` is just a tag name for the purpose of this guide -## Running a CentOS image -The image just created in the previous step allows both stateless or stateful runs. -The stateless run is achieved by: -``` -$ docker run --rm -it -p 61616:61616 -p 8161:8161 artemis-centos -``` -While a stateful run with: -``` -docker run -it -p 61616:61616 -p 8161:8161 -v :/var/lib/artemis-instance artemis-centos -``` -where `` is a folder where the broker instance is supposed to -be saved and reused on each run. - -