#Docker: Custom #JBoss EAP docker image with CLI applied patches and CLI configurations

By | April 11, 2017

In the following I am trying to create a Jboss EAP docker image with up-to-date patches and configurations applied using JBoss CLI.
With this template I can then very easy setup any complex JBoss based application environment with ready defined data sources, connectors , resource adapters etc.
In the following I will describe the steps to create the Dockerfile associated scripts of the image.

STEP 1: Start creation of the Dockerfile from a base image

I will start from the jboss base image with jdk8 available on docker.io

STEP 2: Add the section to install jboss-EAP 7.0.0 base

The following section will install kits/jboss-eap-7.0.0.zip downloaded from Red-Hat official repository (paid support account needed). Make sure to download the zip archive not the installer.
Place the downloaded kit in a kits directory at the same level with the Dockerfile.
Add the following lines to the Dockerfile

The above will set some environment variables like version and home then will copy the jboss-eap kit and install it by unzipping. Note that we also do a clean-up after that.
We set up also an environment variable to “Ensure signals are forwarded to the JVM process correctly for graceful shutdown”.
The last part will expose the ports to the host, where:
– 8080 is the http application port where a deployed application will be listening
– 8443 is the secure https application port where a deployed application will be listening
– 8787 is the application debug port where a deployed application debug will be listening
– 9990 is the http jboss admin console port where jboss administration console will be listening

STEP 3: Prepare to apply the Jboss EAP patches and configurations

Download from the Jboss EAP RedHat repository the latest cumulative patches:

Place them in the same kit directory at the same level with the Dockerfile.

For each patch file create a scripts/patch-7.x.x.cli file containing the line:

To configure the application server environment we are going to use the embed server to create resource adapters, data sources etc.
Create the scripts/setup.cli and scripts/setup.properties which are using the embed-server and CLI code to set up the environment.

A sample scripts/setup.cli defining an Oracle datasource that we will access through hibernate looks like:

Content of scripts/setup.properties where variables are defined

STEP 4: Prepare the datasource driver

We define kits/module.zip a binary archive containing the Oracle driver:

Note that under “modules/oracle/jdbc/main/” we have the ojdbc7.jar driver and a module.xml:

Very important note that the hibernate libraries require to have a module.xml under “modules/system/layers/base/.overlays/layer-base-jboss-eap-7.0.5.CP/org/hibernate/main/” that is a relative path given by the latest patch. Do not ask me why is this, I know is stupid but this is how it works.

STEP 5: Prepare the CLI setup script

I created a bash script to apply the patches and the server configurations. Note that several application server restarts are necessary and they are triggered by the script.
The script also waits after each restart for the Jboss server to start, to make sure the CLI interface is ready.

Create the following “setupJboss.sh”

Note that we have the same block repeated for each patch. If additional patches are released we just have to add a new “patch” block to this script.

STEP 6: Apply the Jboss EAP patches and configurations

Add the following lines to the Dockerfile:

STEP 7: The final Dockerfile and conclusions

At this step we add also the Jboss configurations described in Production #Jboss client image that checks if the #Oracle container is initialized with data to have a proper start script.

The final Dockerfile looks like: