This commit is contained in:
Clebert Suconic 2019-02-05 13:57:29 -05:00
commit 4f758f3dd9
9 changed files with 330 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)") @Option(name = "--http-host", description = "The host name to use for embedded web server (Default: localhost)")
private String httpHost = HTTP_HOST; 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.") @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; private String ping;
@ -774,6 +777,13 @@ public class Create extends InputAbstract {
filters.remove("${artemis.instance}"); filters.remove("${artemis.instance}");
writeEtc(ETC_BOOTSTRAP_XML, etcFolder, filters, false); writeEtc(ETC_BOOTSTRAP_XML, etcFolder, filters, false);
writeEtc(ETC_MANAGEMENT_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); writeEtc(ETC_JOLOKIA_ACCESS_XML, etcFolder, filters, false);
context.out.println(""); context.out.println("");

View File

@ -26,8 +26,9 @@ under the License.
<!-- Allow cross origin access from ${http.host} ... --> <!-- Allow cross origin access from ${http.host} ... -->
<allow-origin>*://${http.host}*</allow-origin> <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> </cors>
</restrict> </restrict>

View File

@ -207,6 +207,7 @@
<exclude>**/**/*.iml</exclude> <exclude>**/**/*.iml</exclude>
<exclude>**/**/*.dat</exclude> <exclude>**/**/*.dat</exclude>
<exclude>**/licenses/**</exclude> <exclude>**/licenses/**</exclude>
<exclude>docker/**</exclude>
</excludes> </excludes>
</fileSet> </fileSet>
<!-- chmod to 755 on linux executables --> <!-- chmod to 755 on linux executables -->

View File

@ -0,0 +1,71 @@
# 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"
# 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
ADD . /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 ./docker/docker-run.sh /
USER artemis
# Expose some outstanding folders
VOLUME ["/var/lib/artemis-instance"]
WORKDIR /var/lib/artemis-instance
ENTRYPOINT ["/docker-run.sh"]
CMD ["artemis-server"]

View File

@ -0,0 +1,71 @@
# 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"
# 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
ADD . /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 ./docker/docker-run.sh /
USER artemis
# Expose some outstanding folders
VOLUME ["/var/lib/artemis-instance"]
WORKDIR /var/lib/artemis-instance
ENTRYPOINT ["/docker-run.sh"]
CMD ["artemis-server"]

41
artemis-docker/docker-run.sh Executable file
View File

@ -0,0 +1,41 @@
#!/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.
# This is the entry point for the docker images.
# This file is executed when docker run is called.
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

View File

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

75
artemis-docker/readme.md Normal file
View File

@ -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 <broker folder on host>:/var/lib/artemis-instance artemis-centos
```
where `<broker folder on host>` is a folder where the broker instance is supposed to
be saved and reused on each run.