ARTEMIS-2245 Implement Docker images
authorClebert Suconic <clebertsuconic@apache.org>
Tue, 23 Oct 2018 01:11:02 +0000 (21:11 -0400)
committerClebert Suconic <clebertsuconic@apache.org>
Tue, 5 Feb 2019 18:32:24 +0000 (13:32 -0500)
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/jolokia-access.xml
artemis-distribution/pom.xml
artemis-distribution/src/main/assembly/docker-assembly.xml [new file with mode: 0644]
artemis-distribution/src/main/resources/docker/Dockerfile [new file with mode: 0644]
artemis-distribution/src/main/resources/docker/assets/docker-entrypoint.sh [new file with mode: 0755]

index cde6515..3982fac 100644 (file)
@@ -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("");
index aff5656..89aa41c 100644 (file)
@@ -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
index af716cc..2618b09 100644 (file)
             <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>
                   </goals>
                </execution>
                <execution>
-                 <id>bin</id>
+                  <id>bin</id>
                   <configuration>
                      <descriptor>src/main/assembly/dep.xml</descriptor>
                      <tarLongFileMode>gnu</tarLongFileMode>
                      <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 (file)
index 0000000..054bd6b
--- /dev/null
@@ -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 (file)
index 0000000..ae34d14
--- /dev/null
@@ -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 (executable)
index 0000000..cd4c3f4
--- /dev/null
@@ -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
+
+