Application packaging

We follow the bring-your-own-runtime mantra. The code repository has the following structure

the source code ( src directory)

directory) Tomcat 8.x ( tom-accs directory)

directory) bootstrap script ( start.sh )

#!/bin/bash

if [ -z “$PORT” ];

then

PORT=”8080"

fi

echo “PORT set to $PORT”

# Update server.xml with env vars

sed “s/__PORT__/${PORT}/g” server.template.xml > tom-accs/conf/server.xml

sh tom-accs/bin/catalina.sh run

In addition to the Tomcat startup script invocation, the start.sh script ensures that the server.xml with correct environment variable ($PORT in our case) is generated during application start up

templated version of (Tomcat) server.xml ( server.xml.template )

( ) manifest.json — the mandatory deployment descriptor

{

“runtime”:{“majorVersion”:”8"},

“command”:”sh ./start.sh”,

“notes”:”Tomcat on ACCCS with Redis Session Sharing”

}

Setup

Oracle Developer Cloud

Let’s configure Oracle Developer Cloud for the Continuous Build as well as Deployment process. You can refer to previous blogs for the same (some of the details specific to this example will be highlighted here)

References

Build Job configuration

The build job for this application is generic in nature, but it has some application specific nuances (Build Steps) which will be highlighted in this section

Build Step #1 — Invoke the Maven build to produce the required artifact i.e. a WAR file in this case

Build Step #2 — copy the WAR file into the Tomcat webapps directory and zip everything up (for the final cloud ready artifact)

The end result is a zip file which consists of the binary (WAR file) as well the runtime (Tomcat installation) where its going to execute

Provide Oracle Application Container Cloud (configuration) descriptor

We provide the application (sizing) details as well as Redis co-ordinates (host and port)

Deployment confirmation in Oracle Developer Cloud

Post-deployment status in Application Container Cloud

Test the application

Let’s test the application using cURL and the redis-cli tool

First time access

We will just invoke a HTTP GET on our application URL

curl https://accs-tomcat-redis-<mydomain>.apaas.em2.oraclecloud.com/accs-tomcat-redis-spring/

This will create a new HTTP session — highlighted in green

Notice the ACCS instance (in green) which processed the request

Add session data & access the application

We will now use the Session ID received above by passing it along with a request which will add some session data — this is a HTTP POST with parameters name and val which are stored in the HTTP session

curl -X POST -H “Cookie: SESSION=09217ecb-6b90–41bf-952f-b41b65070fa2” “https://accs-tomcat-redis-<mydomain>.apaas.em2.oraclecloud.com/accs-tomcat-redis-spring/?name=k1&val=v1"