ARTEMIS-2245 Implement Docker images

This commit is contained in:
Clebert Suconic 2018-10-22 21:11:02 -04:00
parent 91a1ea8811
commit f2a2d6d99f
6 changed files with 185 additions and 4 deletions

View 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("");

View 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>

View File

@ -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>

View File

@ -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>

View File

@ -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"]

View File

@ -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