Deploying a Binary WAR File to Openshift 4 Using s2i
We can leverage s2i to deploy an existing war file into Openshift 4. How to do it is pretty much simple and straight forward, basically just running some oc command and you can have your war file deployed on Openshift.
But before we go far, we need to have a sample application to be deployed and for this sample, i have a hello world apps which is created by using Java Servlet.
https://github.com/edwin/jboss-eap-hello-world
We can clone this application, and build it using a simple maven command.
$ mvn clean package
Next step is create an empty folder where we would run our oc command,
$ mkdir -p jboss-eap/deployments
and we can put our ROOT.war file inside deployment folder,
$ tree .
.
+---- deployments
+---- ROOT.war
Next is creating a new BuildConfig,
$ oc new-build --name=custom-eap-application \ --binary=true --image-stream=jboss-eap74-openjdk11-openshift:latest
and start building it by using a start-build command, we can also repeat this step again if there is a new changes to our war file
$ oc start-build custom-eap-application --from-dir . --follow
and finally we can deploy our application directly by using new-app command,
$ oc new-app --name=custom-eap-application \ --image-stream=edwin-ns/custom-eap-application:latest
So deployment can be done easily by using just 3 simple steps.