Deploying MDM Application (EBX) on Docker
Chapter 2: Container Support for Orchestra Networks’s EBX
In the EBX docker image is a script that includes commands for pulling and installing;
- EBX & JARs (RDBMS driver)
- Tomcat
- Deployment structure (EBX Home, Tomcat Home)
- JDK
The customer deploys the image specifying the following:
- EBX license
- RDBMS connection string
- Source of domain-specific packages (if required)JDK
Installing EBX from local binaries on Tomcat with H2
Application Server: Tomcat
Database: H2
- Public binaries:
- activation.jar
- javax.mail.jar
- h2-1.4.196.jar
- Private binaries:
- EBX Core
- ebx.jar
- ebx-dataservices.war
- ebx-dma.war
- ebx-manager.war
- h2-1.4.196.jar
- ebx-root-1.0.war
- ebx-ui.war
- ebx.war
- EBX Addons
- ebx-addons.jar
- ebx-addon-adix.war
- ebx-addon-common.war
- ebx-addon-daqa.war
- ebx-addon-dmdv.war
- ebx-addon-dqid.war
- ebx-addon-dqid.war
- ebx-addon-moda.war
- ebx-addon-mtrn.war
- ebx-addon-tese.war
- EBX Core
Docker hub contains/hosts several docker images which can be used during docker deployment. We will use tomcat from docker hub.
For the binaries that isn’t publicly hosted. We will have to provide them. Typically, those are hosted on nexus repository but for our implementation we will host them in local file systems.
Prerequisites
- Docker ID
- Create a docker id if you don’t already have one.
- Local docker server
- To download Docker Desktop, go to Docker Hub and sign in with your Docker ID.
- Download from Docker Hub
Install and run Docker Desktop on Mac
- Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder.
- Double-click Docker.app in the Applications folder to start Docker.
- You are prompted to authorize Docker.app with your system password after you launch it. Privileged access is needed to install networking components and links to the Docker apps
- The Docker menu in the top status bar indicates that Docker Desktop is running, and accessible from a terminal.
- If you just installed the app, you also get a message with suggested next steps and a link to the documentation. Click the Docker menu () in the status bar to dismiss this pop-up notification.
- Click the Docker menu () to see Preferences and other options
- Select About Docker to verify that you have the latest version.
Dockerfile
A Docker image consists of read-only layers each of which represents a Dockerfile instruction. The layers are stacked and each one is a delta of the changes from the previous layer. Consider this Dockerfile:
FROM tomcat:9.0.12-jre11
ENV EBX_HOME /data/app/ebx
RUN mkdir -p ${EBX_HOME}
WORKDIR $CATALINA_HOME
COPY ebx-server/conf/context.xml ${CATALINA_HOME}/conf/
CMD ["catalina.sh", "run"]
Each instruction creates one layer:
- FROM creates a layer from the tomcat:9.0.12-jre11 Docker image. You can login to docker official imagesrepository to get the image that you want.
- ENV sets the env variable for EBX_HOME to /data/app/ebx.
- RUN executes the mkdir command and creates the directory
- WORKDIR sets the working directory to CATALINA_HOME.
- COPY adds files from your Docker client’s current directory.
- CMD specifies what command to run within the container.
Here is the complete docker file:
FROM tomcat:8.5.47-jdk8-openjdk
ENV EBX_HOME /data/app/ebx
RUN mkdir -p ${EBX_HOME}
WORKDIR $CATALINA_HOME
COPY ebx-server/conf/context.xml ${CATALINA_HOME}/conf/
COPY ebx-server/conf/logging.properties ${CATALINA_HOME}/conf/
COPY ebx-server/conf/server.xml $CATALINA_HOME/conf/
COPY ebx-server/conf/catalina.properties $CATALINA_HOME/conf/
COPY ebx/*.jks $CATALINA_HOME/
COPY ebx/libs/*.jar $CATALINA_HOME/lib/
COPY ebx/ebx.software/lib/*.jar $CATALINA_HOME/lib/
COPY ebx/ebx.software/lib/lib-h2/*.jar $CATALINA_HOME/lib/
COPY ebx/ebx.software/webapps/*.war $CATALINA_HOME/webapps/
COPY ebx/webapps/*.war $CATALINA_HOME/webapps/
COPY ebx-home/*.properties /data/app/
ENV EBX_OPTS="-Debx.home=${EBX_HOME} -Debx.properties=/data/app/ebx.properties -DebxLicense=${EBXLICENSE}"
###
### startup parameters
ENV JAVA_OPTS="${EBX_OPTS} ${JAVA_OPTS}"
ENV CATALINA_OPTS ""
###
### SECURITY
RUN groupadd -g 1000 user \
&& useradd -u 1000 -g 1000 -m -s /bin/bash user \
&& chown -R 1000 /data /usr/local/tomcat
USER user
VOLUME ["/data/app/ebx"]
EXPOSE 8080
CMD ["catalina.sh", "run"]
Building Docker Image
docker build [OPTIONS] -f- PATH
In order to build the docker image.
- Navigate to the folder location where the Dockerfile is located.
- Login to docker
docker login
- Execute the build command
The example below uses the current directory (.) as the build context, and builds an image using a Dockerfile
docker build -t ebx:5.8.6-tomcat8.0.00-jdk8-openjdk .
–tag , -t Name and optionally a tag in the ‘name:tag’ format
Verify that the image was build and is available inside docker container
docker image ls
you should see the following result in the terminal
REPOSITORY | TAG | IMAGE ID | CREATED | SIZE |
ebx | 5.8.6-tomcat8.0.00-jdk8-openjdk | 1698fd968de9 | About a minute ago | 1.73GB |
tomcat | 8.0.00-jdk8-openjdk | 882487b8be1d | 3 weeks ago | 507MB |
Build was successful. And you are now ready to run the docker image.
Running Docker Image
The basic docker run command takes this form:
$ docker run [OPTIONS] IMAGE [: TAG|@DIGEST] [COMMAND] [ARG...]
The docker run command must specify an IMAGE to derive the container from. An image developer can define image defaults related to:
- detached or foreground running
- container identification
- network settings
- runtime constraints on CPU and memory
With the docker run [OPTIONS] an operator can add to or override the image defaults set by a developer. And, additionally, operators can override nearly all the defaults set by the Docker runtime itself. The operator’s ability to override image and Docker runtime defaults is why run has more options than any other docker command.
Use the following command to run the ebx docker image that we created. In the below example I am overriding the default 9090 port with 8080 port and passing the License key as a parameter.
docker run --rm -p 9090:8080 --mount type=volume,src=ebx1,dst=/data/app/ebx --name ebx1 ebx:5.9.6-tomcat8.5.47-jdk8-openjdk
Container identification
Name (–name)
Using Docker from Maven
For this exercise we can use the new version of the Spotify Docker plugin
The Docker plugin from Spotify supports only two operations:
- building a Docker image and
- pushing a Docker image to the Registry.
The plugin is not calling Docker directly but instead acts as a wrapper around Docker-client (https://github.com/spotify/docker-client) also developed by Spotify.