RESTful JOptTourOptimizer in Docker

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.


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.

Screenshot


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

2) Running a container:

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

Same command as a single line:

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

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)

3) Open: http://localhost:8081

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

Preview:

Screenshot


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.

Update (May 2021):

Info

We enabled almost all features now. Contact us in case you need help!

Please use the new endpoints for starting an Optimization to enable the latest features:

1) /api/optimize/config/run

2) /api/optimize/config/runOnlyResult

The new endpoints are covered by the definition: OptimizationConfig (api-docs)

The previous endpoints moved to the definition: LegacyOptimization (api-docs)


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.

Info

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

The angular-demo application was generated with Angular CLI version 10.1.2. Further, we utilized OpenApi Generator to automatically create the required TypeScript models from the OpenApi definition provided from our Swagger definition of JOptTourOptimizer.


How to start the DNA Demo Application

The demo application is also available on Docker Hub. There are multiple ways on 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 container needs to be started with the profile "cors" as described here in 2).

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)

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 ©