Docker-REST-TourOptimizer

DNA-Evolutions

Containerizing an application helps to use it more conveniently across different platforms and, most importantly, as a microservice. Further, scaling an application becomes more straightforward as different standardized orchestration tools can be utilized. It can be launched either (locally) as part of a docker-compose or as a highly-scalable web-micro-service in a Kubernetes cluster, to give an example.


Contact

If you need any help, please contact us via our company website www.dna-evolutions.com or write an email to info@dna-evolutions.com.


Further Documentation and Links


Overview


Tech Stack - How JOptTourOptimizer is containerized

RESTful JOptTourOptimizer can be used as a Docker container utilizing Spring WebFlux and Swagger. Internally the Java version of TourOptimizer is utilized.

TourOptimizer-Docker-Integration


How to start JOptTourOptimizer-Docker

JOptTourOptimizer is hosted on Docker Hub. In a first step, you can pull the image and start a container in your local docker environment, using, for example, Docker Desktop.

Setup JOptTourOptimizer-Docker

Setting up JOptTourOptimizer in your Docker environment only takes these three steps:

1) Pulling the image:

docker pull dnaevolutions/jopt_touroptimizer:latest

2) Running a container:

docker run -d --rm \
 	--name myJOptTourOptimizer \
 	-e SPRING_PROFILES_ACTIVE="cors" \
 	-p 8081:8081  \
 	dnaevolutions/jopt_touroptimizer:latest

Same command as a single line:

docker run -d --rm  --name myJOptTourOptimizer -e SPRING_PROFILES_ACTIVE="cors" -p 8081:8081  dnaevolutions/jopt_touroptimizer:latest

Activating the profile "cors" will allow doing REST-calls from the same localhost from another application.

(If desired, please adjust docker run argument to your needs)

For a complete list of environment variables, refer to the TourOptimizer Docker Variables documentation.

3) Open: http://localhost:8081

...and you should see the Swagger-Interface.

Preview (click to enlarge):


How to start JOptTourOptimizer-Docker in Fire and Forget Mode

Please refer to the separate Hands-on Tutorial: Setting Up a Local Fire and Forget TourOptimizer-Database Test Environment tutorial.


How to make use of JOptTourOptimizer-Docker

By default, you are allowed to run an Optimization with up to 15 elements without providing a license key. In case you already have a license key for JOptTourOptimizer (Java-Maven) you can use that one.

After you opened http://localhost:8081 you see the Swagger interface of JOptTourOptimizer. You can generate a client in your desired language by using the SwaggerEditor.

Simply copy the Swagger definition under http://localhost:8081/v3/api-docs into the SwaggerEditor and accept to convert JSON to YAML.


DNA Demo Application

To utilize JOptTourOptimizer-Docker, we created an angular-demo application. This demo application is hosted on Microsoft Azure and is made available via https://demo.dna-evolutions.com.

You can access the latest source-code at https://github.com/DNA-Evolutions/Angular-Demo-Application-Source.


How to start the DNA Demo Application

The demo application is also available on Docker Hub. There are multiple ways how you can attach the demo application to JOptTourOptimizer-Docker.

For example:

A) Let the demo container directly access the localhost (CORS eventually needs to be enabled for the browser).

B) Using a docker-compose with both containers. Only expose the demo application if desired.

C) Attaching the demo container to the same network.

...

Setup the Angular DNA Demo Application

In this walkthrough, we let the demo application access the localhost as in A). Next, you need to launch JOptTourOptimizer-Docker in a container as described in the JOptTourOptimizer setup. The page http://localhost:8081 needs to be accessible. Further, the TourOptimizer container needs to be started with the profile "cors" as described above.

1) Pulling the image:

docker pull dnaevolutions/jopt_demoapplication

2) Running a container:

docker run -d --rm \
	--name myJOptTourOptimizerDemo \
	-p 3000:80 \
	-v ${PWD}:/usr/src/app \
	-e JOPT_SWAGGER_HOST="http://localhost" \
	-e JOPT_SWAGGER_PORT="8081" \
	dnaevolutions/jopt_demoapplication

Same command as a single line:

docker run -d --rm --name myJOptTourOptimizerDemo -p 3000:80 -v ${PWD}:/usr/src/app -e JOPT_SWAGGER_HOST="http://localhost" -e JOPT_SWAGGER_PORT="8081" dnaevolutions/jopt_demoapplication

(If desired, please adjust docker run argument to your needs)

For a complete list of environment variables, refer to the TourOptimizer Docker Variables documentation.

3) Open: http://localhost:3000

...and you should see the DNA-Demo-Application.


Agreement

For reading our license agreement and for further information about license plans, please visit www.dna-evolutions.com.


Authors

A product by dna-evolutions ©