I wanted to play around with going back to the roots of java(EE) and wanted to take the docker part a step further.
Why not have the platform as a docker image in such a way that when building the project the docker image will take care of the
deployment automatically after each build.
- Building a Java EE application as easy as possible
- Have all the cool stuff available from MicroProfile
- Stay as close to the core as possible.
- Docker installed
- Java 8 installed
- A sense of adventure :-)
I wanted to make a docker image with Payara 5 on it. See this blog for more information on it.
It has to be configurable is such a way that it does not need to be rebuild every time I create an artifact.
Assume that the war I create will be deployed on a similar server and that I don’t need to deploy the
whole platform every time. So I don’t want to build my docker image every time either
when programming and building my application.
So I need:
- Payara as a docker image ->
- a way to deploy automatically after each maven build
- have it exposed to the local machine
In the image a link has been created between
/autodeploy and the actual autodeploy diretory in the image (see the Dockerfile for more information). This is done for
convenience and ease of reading. Now you can mount this directory as a volume.
In order to do this I have chosen to add a very small part to my maven java project to facilitate the autodeploy feature.
mvn package it will build the war file but also copy the final artifact to the
When starting the created docker container (from the project directory) we can now make sure
that it will mount the
<project>/artifact directory to the
/autodeploy container directory.
This command will run the Payara 5 Full profile server in daemon mode, with the
<project>/artifact folder mounted as a folder to
Now if you build your project:
mvn clean package
it will build the war in the target folder and the plugin defined in the pom.xml file will make sure that the artifact is copied to the
The Payara server is monitoring that folder because it has been mounted to its autodeploy directory and it will see
a new artifact in the directory. Now it will autodeploy that artifact with the artifact name as the rootContext.
So if you project is called
HelloWorld the artifact will be called
./artifact/HelloWorld.war and the url for Payara will become
Every time you rebuild the project with the maven commando’s payara will redeploy the artifact as it will recognise that it has changed.
Now you can build and test your software without having to build a new image every time while still testing against the final environment.
Pretty cool if I do say so myself 😄
While creating the image I had started out with a small alpine openjdk 1.8 docker image,
but to my dismay it threw this error
when I tried to enable the remote Admin console. In the end I got it to work on a CentOs with a java 1.8.0_191 version
installed on it.
I must say that it was a big surprise for me that this bug was there and I will try again with standard
OpenJdk versions at a later date as I also want to migrate to Java 11+ but for now it is what it is 😄
This feature is also used in projects generated with this Maven Archetype.