Deploy a WildFly Jakarta EE 10 application on OpenShift

Deploy a WildFly Jakarta EE 10 application on OpenShift

Intro

In this article we show HOW-TO deploy on OpenShift a Jakarta EE 10 application using WildFly as runtime;

You can find further details here wildfly.org/news/2022/04/20/WildFly-s2i-v2-..;

We show two variants of the process, each corresponding a different workflow:

  1. for development, using an OpenShift binary build

  2. for production, using an OpenShift build from a git repository

for development, using an OpenShift binary build

First we clone locally the git repository containing the Jakarta EE 10 application we want to deploy; we will deploy our local copy on OpenShift: you can also remove the .git folder from the local copy to prove the remote git repository isn't used;

Note that this project uses the wildfly-maven-plugin (github.com/tommaso-borgato/openshift-jee-sa..) in order to provision a WildFly server with the application already deployed;

git clone https://github.com/tommaso-borgato/openshift-jee-sample
cd openshift-jee-sample
git fetch origin jakartaee
git checkout jakartaee
rm -rdf .git

Next, we create an OpenShift binary build;

Note we are using the builder image quay.io/wildfly/wildfly-s2i-jdk11:latest which is capable of running a maven build on our source code;

oc new-project eap8-binary-source

oc new-build --name=eap8-binary-source \
  --labels=appsint.app=eap-test-app \
  --binary=true \
  --strategy=source \
  --env=ADMIN_USERNAME=admin \
  --env=ADMIN_PASSWORD=pass.1234 \
  --env=MAVEN_ARGS_APPEND="-Dserver-feature-pack.location=org.wildfly:wildfly-galleon-pack:27.0.0.Alpha4 -Dcloud-feature-pack.location=org.wildfly.cloud:wildfly-cloud-galleon-pack:2.0.0.Alpha4" \
  --image=quay.io/wildfly/wildfly-s2i-jdk11:latest

oc start-build eap8-binary-source \
  --from-dir=$PWD \
  --follow

Once the OpenShift binary build completes, we have the imagestream.image.openshift.io/eap8-binary-source which contains the WildFly server with the application already deployed;

Finally we run the application:

oc new-app eap8-binary-source

At this point, you can change the code you have locally with your preferred Java IDE and redeploy the application at any time with:

oc start-build eap8-binary-source \
  --from-dir=$PWD \
  --follow

for production, using an OpenShift build from a git repository

As you can see, the workflow is shorter, since we don't have to use a git repository for the build:

oc new-project eap8-git-source

oc new-app https://github.com/tommaso-borgato/openshift-jee-sample.git#jakartaee \
  --name=eap8-git-source \
  --labels=appsint.app=eap-test-app \
  --as-deployment-config=true \
  --strategy=source \
  --build-env=ADMIN_USERNAME=admin \
  --build-env=ADMIN_PASSWORD=pass.1234 \
  --build-env=MAVEN_ARGS_APPEND="-Dserver-feature-pack.location=org.wildfly:wildfly-galleon-pack:27.0.0.Alpha4 -Dcloud-feature-pack.location=org.wildfly.cloud:wildfly-cloud-galleon-pack:2.0.0.Alpha4" \
  --image=quay.io/wildfly/wildfly-s2i-jdk11:latest