Guidelines on Building Application

This section explains the steps necessary for building your application and deploying it on the NUBOMEDIA PaaS. The NUBOMEDIA PaaS uses OpenShift v3 as backend technology, which supports docker containers. All you need to do in order to deploy your application on the PaaS is to create a dockerfile containing the instructions on how to build your application (from binaries or source code), add it into a git repository, and use the PaaS dashboard for uploading it to NUBOMEDIA.

Please follow the instructions below for deploying an application either from source code or binaries.

Building from Source Code

To build an application using the source code version the following steps are necessary:

  • Create you Dockerfile (see the section below for more details) with all the instructions to copy the source code inside a directory (like the ADD my-code-folder /tmp/my-code-folder)

  • Move inside the directory and run all the commands required for build

  • Declare an ENTRYPOINT with the command required for run.

  • Create a Git repository (private or public) and put inside your code plus Dockerfile

  • Deploy the application on the PaaS-manager with the same procedure, if something on your Dockerfile is wrong the build will fail. We suggest you to try building/running the dockerfile on your local docker environment first.

Maven and JDK 8 are already installed in the base-image (named: nubomedia/apps-baseimage:src) so you don't need to install anything.

An example of this kind of deployment can be found here). In addition, the tutorials described in this documentation follow also this approach: magic-mirror, repository, room.

Building from Jar

To build an application using binaries (an example can be found here) the following steps are necessary:

  • Create a Dockerfile that describes the way of running the application in the platform

  • Upload JAR and Dockerfile to a GitHub repository

  • Deploy the application using the PaaS GUI or the REST API

Write a Dockerfile

Write a Dockerfile to install and run the application on the PaaS, the file has to be located in the same repository of the application. Here is an example of a sample nubomedia app:

FROM nubomedia/apps-baseimage:v1


RUN mkdir /tmp/magic-mirror
ADD nubomedia-magic-mirror-6.2.2-SNAPSHOT.jar /tmp/magic-mirror/
ADD keystore.jks /

EXPOSE 8080 8443 443

ENTRYPOINT java -jar /tmp/magic-mirror/nubomedia-magic-mirror-6.2.2-SNAPSHOT.jar

Here are some explanations from the example above.

  • nubomedia/apps-baseimage:src is the Nubomedia base image to build and run the application, is based on alpine linux with java 8 and bash installed; it also have is internal packet manager to install other packages. We choose that because with ubuntu-based images we had build problems and very low performances

  • MAINTAINER is the developer of the application (and the author of the Dockerfile)

  • RUN is a Docker instruction that execute a command given as parameter, any misspelling or wrong parameters will result in a build failure

  • ADD is a simple cut and paste from base directory to given directory

  • EXPOSE is used to declare the ports that will be used from the docker container, which will also be used by OpenShift

  • ENTRYPOINT is the command that docker will execute after the creation of the container.

For an extensive list of Docker commands and references use the following resources:

Building from Private Repository

The procedure to build from a private repository is similar to the procedure for deploying from a public repository, with just one additional step the user needs to carry out. You will need to send an HTTP request to the PaaS Manager to create a secret. This secret is used to securely clone your repository during the build process.

Creating a Secret

You can store a secret via the graphical interface or via a REST client (e.g. curl) on the URL http://[URL]/api/v1/nubomedia/paas/secret with the json as follows:

    "privateKey":"-----BEGIN RSA PRIVATE KEY-----\n
    -----END RSA PRIVATE KEY-----"

Note The private key value must preserve newlines, use \n to preserve it.

Above is an example of what the private RSA Key looks like. Replace it with your generated private key. For more information on generating RSA private key, check the GitHub documentation.

The GUI (or the Http request) will return the secretname that has to be used when you want to deploy the application as described in deploying via PaaS GUI or in deploying via PaaS API.