View on GitHub

JGU WEKA REST Service

RESTful API Webservice to WEKA Machine Learning Algorithms.

Dockerized Development Environment Setup

This describes an example dockerized development environment for a Java web project with a MongoDB database. A Jenkins server is used as a build setup for the code deployment. A Tomcat container hosts the application war file. Jenkins and Tomcat do share a file storage for easy deployment via copying within the Jenkins instance.

MongoDB Setup

Start a MongoDB container with a local file storage, restart policy and container name:

docker run -d --restart unless-stopped --name mongodb -v ~/mongodb:/data/db mongo

You can access MongoDB by local its IP not from the intenet.

Tomcat Container Setup

docker run -d --restart unless-stopped --name tomcat --link mongodb:mongodb -p 8081:8081 -v ~/jenkins/workspace/tomcat:/usr/local/tomcat/webapps tomcat:8.0-jre8

Add a proxy entry to /usr/local/tomcat/conf/server.xml to proxy from host Apache2 or Nginx to the Tomcat docker IP:8081

<Connector port="8081" proxyPort="8081"/>

If you want to use OpenTox Authorization and Authentication you have to install a security certificate to the tomcat truststore. (This is used to connect to https://openam.in-silico.ch.)

Download the certificate from https://openam.in-silico.ch with openssl:

openssl s_client -showcerts -connect openam.in-silico.ch:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >in-silicoch.crt

Import it into the Tomcat truststore

docker cp in-silicoch.crt ORN_tomcat:/usr/local/tomcat
docker exec -it ORN_tomcat keytool -keystore /etc/ssl/certs/java/cacerts -importcert -alias openam.in-silico.ch -file in-silicoch.crt

Tomcat Setup with Dockerfile

Alternative you can build the tomcat image and container with needed certificate and java application with the Dockerfile.

docker build -t jguweka/jguweka -f Dockerfile .
docker run -d  -p 0.0.0.0:8080:8080 jguweka/jguweka

For Keycloak authentication do this with Dockerfile-keycloak.
Adjust settings for Keycloak as described in Tomcat Keycloak Setup

docker build -t jguweka/jguweka:keycloak -f Dockerfile-keycloak .
docker run -d  -p 0.0.0.0:8080:8080 jguweka/jguweka:keycloak

Jenkins

Run a Jenkins Docker container on port 8089, with a filestorage on the hosts machine. Here the jenkins_home directory is stored at ~/jenkins in your homedirectory on the host machine.

docker run -e JENKINS_OPTS="--httpPort=8089" -p 8089:8089 -p 50000:50000 -v  ~/jenkins:/var/jenkins_home jenkins

Jenkins project setup

Login to the jenkins web UI add a new project with the New Item button.

Apache2 Setup

Enable mod proxy on the host computer.

a2enmod proxy proxy_html proxy_http

Add the proxying to the /etc/apache2/sites-enabled/ configuration file

ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/