Skip to content

Commit

Permalink
ARTEMIS-2776 Improve Dockerfiles
Browse files Browse the repository at this point in the history
Fixes the Dockerfiles handling of ANONYMOUS_LOGIN and adds an
EXTRA_ARGS environment variable to allow specifying extra arguments
separate from the username, password and anonymous login options.
  • Loading branch information
zekeoptimo authored and clebertsuconic committed May 27, 2020
1 parent 0c3ced6 commit 44e15b0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion artemis-docker/Dockerfile-centos
Expand Up @@ -26,7 +26,7 @@ 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
ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia

USER root

Expand Down
2 changes: 1 addition & 1 deletion artemis-docker/Dockerfile-debian
Expand Up @@ -26,7 +26,7 @@ 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
ENV EXTRA_ARGS --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 \
Expand Down
8 changes: 8 additions & 0 deletions artemis-docker/docker-run.sh
Expand Up @@ -28,6 +28,14 @@ BROKER_HOME=/var/lib/
CONFIG_PATH=$BROKER_HOME/etc
export BROKER_HOME OVERRIDE_PATH CONFIG_PATH

if [[ ${ANONYMOUS_LOGIN,,} == "true" ]]; then
LOGIN_OPTION="--allow-anonymous"
else
LOGIN_OPTION="--require-login"
fi

CREATE_ARGUMENTS="--user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent ${LOGIN_OPTION} ${EXTRA_ARGS}"

echo CREATE_ARGUMENTS=${CREATE_ARGUMENTS}

if ! [ -f ./etc/broker.xml ]; then
Expand Down
34 changes: 25 additions & 9 deletions artemis-docker/readme.md
Expand Up @@ -13,7 +13,7 @@ $ ./prepare-docker.sh $ARTEMIS_HOME

Go to `$ARTEMIS_HOME` where you prepared the binary with Docker files.

## For Debian:
## For Debian

From within the `$ARTEMIS_HOME` folder:
```
Expand All @@ -30,21 +30,37 @@ $ docker build -f ./docker/Dockerfile-centos -t artemis-centos .
**Note:**
`-t artemis-debian`,`-t artemis-centos` are just tag names for the purpose of this guide

# Variables:

- ARTEMIS_USER
- ARTEMIS_PASSWORD
- ANONYMOUS_LOGIN
# Environment Variables

Default here is FALSE. If you set this to true, it will change security settings passed on the broker instance creation.
Environment variables determine the options sent to `artemis create` on first execution of the Docker
container. The available options are:

- CREATE_ARGUMENTS
**`ARTEMIS_USER`**

Default here is `--user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent --http-host 0.0.0.0 --relax-jolokia`
The administrator username. The default is `artemis`.

**`ARTEMIS_PASSWORD`**

This will be passed straight to `./artemis create` during the execution.
The administrator password. The default is `artemis`.

**`ANONYMOUS_LOGIN`**

Set to `true` to allow anonymous logins. The default is `false`.

**`EXTRA_ARGS`**

Additional arguments sent to the `artemis create` command. The default is `--http-host 0.0.0.0 --relax-jolokia`.
Setting this value will override the default. See the documentation on `artemis create` for available options.

**Final broker creation command:**

The combination of the above environment variables results in the `docker-run.sh` script calling
the following command to create the broker instance the first time the Docker container runs:

${ARTEMIS_HOME}/bin/artemis create --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --silent ${LOGIN_OPTION} ${EXTRA_ARGS}

Note: `LOGIN_OPTION` is either `--allow-anonymous` or `--require-login` depending on the value of `ANONYMOUS_LOGIN`.

# Mapping point

Expand Down

0 comments on commit 44e15b0

Please sign in to comment.