javaPS Docker Process Repository

52°North Maven Parent Project

License

License

Categories

Categories

Docker Container Virtualization Tools
GroupId

GroupId

org.n52.wps
ArtifactId

ArtifactId

docker-backend
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

javaPS Docker Process Repository
52°North Maven Parent Project
Project URL

Project URL

https://github.com/52North/javaPS-docker-backend
Project Organization

Project Organization

52North Initiative for Geospatial Open Source Software GmbH
Source Code Management

Source Code Management

https://github.com/52North/javaPS-docker-backend

Download docker-backend

How to add to project

<!-- https://jarcasting.com/artifacts/org.n52.wps/docker-backend/ -->
<dependency>
    <groupId>org.n52.wps</groupId>
    <artifactId>docker-backend</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.n52.wps/docker-backend/
implementation 'org.n52.wps:docker-backend:1.0.0'
// https://jarcasting.com/artifacts/org.n52.wps/docker-backend/
implementation ("org.n52.wps:docker-backend:1.0.0")
'org.n52.wps:docker-backend:jar:1.0.0'
<dependency org="org.n52.wps" name="docker-backend" rev="1.0.0">
  <artifact name="docker-backend" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.n52.wps', module='docker-backend', version='1.0.0')
)
libraryDependencies += "org.n52.wps" % "docker-backend" % "1.0.0"
[org.n52.wps/docker-backend "1.0.0"]

Dependencies

compile (15)

Group / Artifact Type Version
org.n52.wps : transactional jar 1.6.0
org.n52.wps : engine jar
joda-time : joda-time jar 2.10.6
com.google.guava : guava jar
org.apache.commons : commons-compress jar 1.20
org.n52.arctic-sea : janmayen jar
org.n52.arctic-sea : shetland jar
org.springframework : spring-beans jar
org.springframework : spring-context jar
com.github.docker-java : docker-java-core jar 3.2.5
com.github.docker-java : docker-java-api jar 3.2.5
com.github.docker-java : docker-java jar 3.2.5
org.slf4j : slf4j-api jar
org.springframework.boot : spring-boot-autoconfigure jar 2.3.4.RELEASE
com.google.code.findbugs : jsr305 jar 3.0.2

provided (1)

Group / Artifact Type Version
com.github.spotbugs : spotbugs-annotations jar 4.1.3

runtime (2)

Group / Artifact Type Version
org.slf4j : jcl-over-slf4j jar
org.n52.arctic-sea : svalbard-json jar 8.0.1

test (3)

Group / Artifact Type Version
junit : junit jar
org.hamcrest : hamcrest-all jar
org.mockito : mockito-core jar

Project Modules

There are no modules declared in this project.

JavaPS Docker Backend Setup Guide

This page aims to guide developers on how to create and add new custom processes to JavaPS using Docker images.

How can the javaPS Docker backend be extended with additional Docker-based processes?

To add a new processes to the javaPs Docker backend you need to create a JSON file that contains a process description and the docker image that contains your service. Then you need to add some configuration to enable the javaPS Docker backend.

javaPS Docker backend will parse the json file to get the image that you specified ,create a container form it and to create a dynamic description of your process.

docker-backend

JavaPs depends on a docker-backend that is responsible for adding new services using docker containers. It automates the process of adding new services to the javaPs by parsing a json file that contains a description of the added service.

javaps-rest

javaps-rest REST/JSON Binding for javaPS and responsible for the documentation of the Web service .it provides information dynamically through hypermedia concerning the existing services. and gets the required information from the json file which contains the service description

Service Description Example

{
  "processDescription": {
    "process": {
      "id": "org.n52.docker.StringReplace",
      "title": "StringReplace",
      "description": "this process replaces he wps in a text to a javaPs",
      "version": "1.0.0",
      "keywords": [
        "string"
      ],
      "inputs": [
        {
          "id": "source",
          "title":"Source input text",
          "description": "Source input text to be replaced",
          "minOccurs": 1,
          "maxOccurs": 1,
          "input": {
            "formats": [
              {
                "mimeType": "text/plain",
                "default": true
              }
            ]
          }
        }],
      "outputs": [
        {
          "id": "output",
          "title":  "text after processing",
          "output": {
            "formats": [
              {
                "mimeType": "text/plain",
                "default": true
              }
            ]
          }
        }
      ]
    },
    "jobControlOptions": [
      "sync-execute"
    ],
    "outputTransmission": [
      "value"
    ]
  },
  "immediateDeployment": true,
  "executionUnit": [
    {
      "unit": {
        "type": "docker",
        "image": "mohammedsaad/service:2.0"
      }
    }
  ],
  "deploymentProfileName": "http://www.opengis.net/profiles/eoc/dockerizedApplication"
}

so all what is required after creating the json file are the following steps of configration

  • creating a DockerConfiguration that implements DockerEnvironmentConfigurer as in the following example @Value("${scihub.password}") will be included from the environment variables
  • then Initial Algorithm Configuration that implements TransactionalAlgorithmConfigurer as in the following example
package org.n52.javaps.eopad;

import org.n52.faroe.ConfigurationError;
import org.n52.javaps.docker.DockerEnvironmentConfigurer;
import org.n52.javaps.docker.Environment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.util.Objects;

@Configuration
public class DockerConfiguration implements DockerEnvironmentConfigurer {
    private static final String SCIHUB_PASSWORD = "SCIHUB_PASSWORD";
    private static final String SCIHUB_USERNAME = "SCIHUB_USERNAME";

    private String username;
    private String password;

    @Value("${scihub.username}")
    public void setUsername(String username) {
        this.username = Objects.requireNonNull(username);
    }

    @Value("${scihub.password}")
    public void setPassword(String password) {
        this.password = Objects.requireNonNull(password);
    }

    @Override
    public void configure(Environment environment) {
        if (username == null || username.isEmpty() ||
            password == null || password.isEmpty()) {
            throw new ConfigurationError("missing SCIHUB credentials");
        }
        environment.put(SCIHUB_USERNAME, username);
        environment.put(SCIHUB_PASSWORD, password);
    }
}

you can add different processes using configuration.addAlgorithmFromResource(algorithmSource)

package org.n52.javaps.eopad;

import org.n52.javaps.transactional.TransactionalAlgorithmConfiguration;
import org.n52.javaps.transactional.TransactionalAlgorithmConfigurer;
import org.springframework.context.annotation.Configuration;

@Configuration
public class InitialAlgorithmConfiguration implements TransactionalAlgorithmConfigurer {

    private static final String NDVI
            = "https://raw.githubusercontent.com/52North/eopad-docker/master/ndvi/application-package.json";
    private static final String QUALITY
            = "https://raw.githubusercontent.com/52North/eopad-docker/master/quality/application-package.json";

    @Override
    public void configure(TransactionalAlgorithmConfiguration configuration) {
        configuration.addAlgorithmFromResource(NDVI).addAlgorithmFromResource(QUALITY);
    }
}

Request/Response pattern

Request:

  • request:
POST <http://localhost:8080/rest/processes/org.n52.docker.StringReplace/jobs> HTTP/1.1
Content-Type: application/json
  • request body:
{
    "inputs":[
      {
          "id":"source",
          "input":{
            "format":{
                "mimeType":"text/plain"
            },
            "value": "The string 'WPS is the best' can be replaced"
          }
      }
    ],
    "outputs":[
      {
          "id":"output",
          "format":{
            "mimeType":"text/plain"
          },
          "transmissionMode":"value"
      }
    ]
}

Response:

the response to the previous request will contain a URL with the job id in the response header .

after requesting the result from the provided URL in the header the response pattern will look like:

{
    "outputs":[
      {
          "id":"output",
          "value":{
            "inlineValue":"The string 'javaPS is the best' can be replaced"
          }
      }
    ]
}
org.n52.wps

52°North Initiative for Geospatial Open Source Software GmbH

Versions

Version
1.0.0