You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/02/05 18:57:48 UTC

[activemq-artemis] 01/05: ARTEMIS-2245 Implement Docker images

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit f2a2d6d99fcffccddec411fbff50c655c3ba1dd1
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Mon Oct 22 21:11:02 2018 -0400

    ARTEMIS-2245 Implement Docker images
---
 .../activemq/artemis/cli/commands/Create.java      |  10 ++
 .../artemis/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 +++++++++++++++++++++
 .../resources/docker/assets/docker-entrypoint.sh   |  18 ++++
 6 files changed, 185 insertions(+), 4 deletions(-)

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 cde6515..3982fac 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}", "<!-- option relax-jolokia used, so strict-checking will be removed here -->");
+      } else {
+         filters.put("${jolokia.options}", "<!-- Check for the proper origin on the server side, too -->\n" +
+                     "        <strict-checking/>");
+      }
       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 aff5656..89aa41c 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.
         <!-- Allow cross origin access from ${http.host} ... -->
         <allow-origin>*://${http.host}*</allow-origin>
 
-        <!-- Check for the proper origin on the server side, too -->
-        <strict-checking/>
+
+        <!-- Options from this point on are auto-generated by Create.java from the Artemis CLI -->
+        ${jolokia.options}
     </cors>
 
 </restrict>
\ No newline at end of file
diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml
index af716cc..2618b09 100644
--- a/artemis-distribution/pom.xml
+++ b/artemis-distribution/pom.xml
@@ -242,7 +242,7 @@
             <artifactId>maven-assembly-plugin</artifactId>
             <version>${maven.assembly.plugin.version}</version>
             <executions>
-               <execution>
+              <execution>
                   <id>source</id>
                   <configuration>
                      <descriptor>src/main/assembly/source-assembly.xml</descriptor>
@@ -254,7 +254,7 @@
                   </goals>
                </execution>
                <execution>
-                 <id>bin</id>
+                  <id>bin</id>
                   <configuration>
                      <descriptor>src/main/assembly/dep.xml</descriptor>
                      <tarLongFileMode>gnu</tarLongFileMode>
@@ -264,6 +264,17 @@
                      <goal>single</goal>
                   </goals>
                </execution>
+               <execution>
+                  <id>docker</id>
+                  <configuration>
+                     <descriptor>src/main/assembly/docker-assembly.xml</descriptor>
+                     <tarLongFileMode>gnu</tarLongFileMode>
+                  </configuration>
+                  <phase>package</phase>
+                  <goals>
+                     <goal>single</goal>
+                  </goals>
+               </execution>
             </executions>
          </plugin>
       </plugins>
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 0000000..054bd6b
--- /dev/null
+++ b/artemis-distribution/src/main/assembly/docker-assembly.xml
@@ -0,0 +1,40 @@
+<!--
+  ~ 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.
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+
+   <id>docker</id>
+   <formats>
+      <format>dir</format>
+   </formats>
+   <includeBaseDirectory>false</includeBaseDirectory>
+
+   <fileSets>
+      <fileSet>
+         <directory>${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version}</directory>
+         <outputDirectory>/build/opt/activemq-artemis</outputDirectory>
+         <useDefaultExcludes>true</useDefaultExcludes>
+     </fileSet>
+      <fileSet>
+         <directory>src/main/resources/docker</directory>
+         <outputDirectory>/build</outputDirectory>
+         <useDefaultExcludes>true</useDefaultExcludes>
+      </fileSet>
+   </fileSets>
+</assembly>
diff --git a/artemis-distribution/src/main/resources/docker/Dockerfile b/artemis-distribution/src/main/resources/docker/Dockerfile
new file mode 100644
index 0000000..ae34d14
--- /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 0000000..cd4c3f4
--- /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
+
+