jBPM, Springboot, and Docker

A Springboot application runs in docker very well and so runs in the cloud very well. This capability is added by default to the jBPM sample applications.

  • third-business-application-kjar: Same as second-business-application-kjar.
  • third-business-application-service: pom.xml modified to point to ../third-business-application-kjar/target/ directory.

No modification is required to run the springboot-jBPM api under docker but the build process done by maven probably needs to be inspected and updated.

The third-business-application-service/pom.xml file references the local-repository directory in the third-business-application-kjar/target.

<fileSet>
  <directory>../third-business-application-kjar/target/local-repository/maven</directory>
  <outputDirectory>opt/jboss/.m2/repository</outputDirectory>        
</fileSet>

This is part of the fabric8-maven-plugin maven plugin which invokes docker to build the docker image. In order for the plugin to build the correct docker image the <directory> value must point to the kjar project. Note that there are two places in the pom.xml that has this setting. You can change them both — one is for building a plain docker image and the other is for building an openshift docker image.

Building the docker image is a two step process. First the kjar local-repository must be built so that it can be included in the service project.

Build the kjar project first from the third-business-application-kjar project.

mvn clean install -Ddocker

Notice that the docker profile is activated with a property setting instead of the usual maven -P setting. Once built there should be a directory target/local-repository in the third-business-application-kjar project.

Build the docker image from the third-business-application-service project. Be sure that you have an internet connection and docker is properly working on your system. The plugin will download the fabric8/java-jboss-openjdk8-jdk image for the OS and Java runtime.

mvn clean install -Ddocker -Ph2

Now the docker image can be run.

docker run -p 8080:8090 apps/business-application-service:1.0-SNAPSHOT

and the API can be tested with curl

curl http://localhost:8080/hello?name=test

Published by Karl

Software Developer

Leave a comment

Design a site like this with WordPress.com
Get started