Link Search Menu Expand Document

Hands on: Add new module to Nuvla

Try to define your own application within Nuvla, using an existing docker image. For example, you might try a web server:

import os

# Creates the services and credenials needed for the ESA Swarm/Minio
# infrastructure for GNSS.
# The following environmenal variables can/must be defined:
# NUVLA_ENDPOINT: endpoint of Nuvla server, defaults to localhost
# NUVLA_USERNAME: username to access Nuvla
# NUVLA_PASSWORD: password to access Nuvla

from nuvla.api import Api as nuvla_Api

nuvla_api = nuvla_Api(os.environ['NUVLA_ENDPOINT'], insecure=True)

nuvla_api.login_password(os.environ['NUVLA_USERNAME'], os.environ['NUVLA_PASSWORD'])

# Add component for nginx web server

gnss_comp = {"author": "nginx",
             "commit": "initial commit",
             "architectures": ["amd64"],,
             "image": {"image-name": "nginx",
                       "tag": "latest"},
             "ports": [{"protocol": "tcp",
                        "target-port": 80}],
             "urls": [["web server", "http://${hostname}:${tcp.80}"]],

gnss_module = {"name": "Nginx Web Server",
               "description": "bare bones nginx web server",
               "logo-url": "",
               "subtype": "component",
               "path": "nginx",
               "parent-path": "",
               "data-accept-content-types": ["text/plain", "application/octet-stream"],
               "content": gnss_comp}

gnss_module_response = nuvla_api.add('module', gnss_module)
gnss_module_id =['resource-id']
print("module id: %s\n" % gnss_module_id)

This will deploy nginx and should allow you to see the standard welcome page. If you have an image that you use frequently, you might try to define an application in Nuvla with that image.

Some questions you might ask about the application definitions:

  • What happens if you don’t define the accepted data types?

  • Is the data you selected actually visible?

  • What limitations do you see when using an standard Docker image with Nuvla?