Cantara 5.1 and Docker - A Brief Guide
Requirements:
- A Docker client. Check the isntallation and setup documentation for your OS:
- Gcloud cli tools: https://cloud.google.com/sdk/install
On This Page
Creating Cantara Images:
- Use this section if creating Cantara container images from scratch -
Refer to the tomcat installation guide for detailed information on context.xml and other configuration information
- Once docker is installed, create 3 separate folders, one each for the worker, assur and console container images.
- Inside each folder create the etc and logs folders. Add the configuration.json files relevant to each to the etc folder.
- Add a worker.properties file to the worker/etc folder and define the hostname as needed.
- Create a folder called tomcatjars in each server folder, add the following jars to this folder, use appropriate versions:
- javax.mail.jar
- mysql-connector-java-x.x.xx.jar
- In the worker folder create a folder called cantaralib, add the following jars to it:
- AIS_Client
- Base_JAR
- JdeNet_JAR
- jmxremote_optional
- jmxri.jar
- ManagementAgent_JAR
- System_JAR
- xmlparserv2
- In each server folder create and configure the context files:
- cantara.xml for worker
- console.xml for console
- assur.xml for assur
- Add a server.xml with appropriate configuration as needed to each folder. As each container is isolated, the default tomcat server.xml file can be left in place.
- Copy the respective exploded war folders to each server folder:
- worker.war for worker
- assur.war for assur
- console.war for console
- Create a file called"Dockerfile" in each folder. Copy in the following content:
Worker Dockerfile
#Install JDK
FROM openjdk:8u212-b04-jdk
#Install tomcat
FROM tomcat:9.0.21-jdk8-openjdk
WORKDIR /usr/local/tomcat
#Copy files to appropriate locations
COPY worker.war /worker/worker.war/
COPY etc /worker/etc/
COPY logs /worker/logs/
COPY /cantaralib/*.jar /worker/worker.war/WEB-INF/lib/
COPY /tomcatjars/*.jar /usr/local/tomcat/lib/
COPY cantara.xml /usr/local/tomcat/conf/Catalina/localhost/
COPY server.xml /usr/local/tomcat/conf/
#Set container port
EXPOSE 8080
#Set java environment options
ENV JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dcantara.worker.etc=/worker/etc"
ENTRYPOINT ["catalina.sh", "run"]
Assur Dockerfile
#Install jdk
FROM openjdk:8u212-b04-jdk
#Install tomcat
FROM tomcat:9.0.21-jdk8-openjdk
WORKDIR /usr/local/tomcat
#Copy files to appropriate locations
COPY assur.war /assur/assur.war/
COPY etc /assur/etc/
COPY logs /assur/logs/
COPY /tomcatjars/*.jar /usr/local/tomcat/lib/
COPY assur.xml /usr/local/tomcat/conf/Catalina/localhost/
COPY server.xml /usr/local/tomcat/conf/
#Set container port
EXPOSE 8080
#Set java environment options
ENV JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dcantara.assur.etc=/assur/etc"
ENTRYPOINT ["catalina.sh", "run"]
Console Dockerfile
#Install JDK
FROM openjdk:8u212-b04-jdk
#Install tomcat
FROM tomcat:9.0.21-jdk8-openjdk
WORKDIR /usr/local/tomcat
#Copy files to appropriate locations
COPY console.war /console/console.war/
COPY etc /console/etc/
COPY logs /console/logs/
COPY /tomcatjars/*.jar /usr/local/tomcat/lib/
COPY console.xml /usr/local/tomcat/conf/Catalina/localhost/
COPY server.xml /usr/local/tomcat/conf/
#Set container port
EXPOSE 8080
#Set java environment options
ENV JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dcantara.console.etc=/console/etc"
ENTRYPOINT ["catalina.sh", "run"]
Building an Image:
Once the server folders are configured navigate to the folder to build (i.e. console/worker/assur) in a terminal and run:
docker build -t [console/worker/assur]-[version]-[config] .
Version should be in the for 5xx, i.e. 514. Use config to label the build according to the specific configuration setup, i.e. rnmtest for Rinami Test.
Take note of the final period after the tag.
Running an Image:
From a terminal enter the following command:
docker run -d -p [EXTERNALPORT]:[CONTAINERPORT] -t [console/worker/assur]-[version]-[config]
Accessing a Running Image:
Docker autogenerates container names when running, to find the name of your container run:
docker container ls
Find the container you want to access and run:
docker container exec -it [container-id] bash
This will start a bash shell for the container.
Publishing an image:
We're using Google Cloud Platform's native container registry to publish container images.
Refer to this guide to configure gcloud to work with docker:
https://cloud.google.com/container-registry/docs/advanced-authentication
Then refer to this guide to push and pull:
https://cloud.google.com/container-registry/docs/pushing-and-pulling?hl=en_US&_ga=2.115601158.-1803574576.1560815708#pushing_an_image_to_a_registry
For:
[HOSTNAME]/[PROJECT-ID]/[IMAGE]
use gcr.io as HOSTNAME and cantara-cloud-dev as PROJECT-ID unless otherwise specified. Your tag should look like this:
"gcr.io/cantara-cloud-dev/console-514-rnmtest"