Deploy a Custom Marketplace Application

Estimated reading time: 4 minutes

You can create custom marketplaces, in addition to the Default Marketplace. Then, you can add Docker container-based applications to custom marketplaces. These instructions illustrate how to add the Python Web Server application to a custom marketplace.This example uses public GitHub and Docker repositories.

The following steps describe how to deploy marketplace applications that are not a part of the default marketplace repository:

See also:

Prerequisites

  • Docker Experience
  • GitHub Experience

Create a Docker Image

You must configure Docker and Github before you can configure a custom marketplace in OT Link Platform.

  1. Create a project directory named python-webserver under the “~/” directory.
  2. Create a Dockerfile with the following content:

    FROM ubuntu
    RUN apt-get update
    RUN apt-get -y install python
    RUN apt-get clean
    EXPOSE 8000
    CMD [ "python", "-m", "SimpleHTTPServer" ]
    
  3. Build the Docker image: $ ~/python-webserver> docker build -t python-webserver .
  4. Create a Docker repository in Docker Hub (https://hub.docker.com) with the name: <your username>/python-webserver
  5. Push the python-webserver image to the Docker Hub:

    $ ~/python-webserver> docker login —-username=yourhubusername
    $ ~/python-webserver> docker tag python-webserver <your username>/python-webserver
    $ ~/python-webserver> docker push <your username>/python-webserver
    

Create a Marketplace Catalog in GitHub

GitHub serves as the filesystem for this git-based marketplace. Take the following steps in GitHub, in preparation for configuring a custom marketplace in OT Link Platform.

  1. Log in to your github.com account.
  2. Create a git repository with the name: demo-marketplace.
  3. Pull the git repository to your local computer: ~/demo-marketplace
  4. Create a templates folder under: ~/demo-marketplace
  5. Create a python-webserver folder under:~/demo-marketplace/templates
  6. Create a readme.mdfile to describe the application under:~/demo-marketplace/templates
  7. Create a config.yml file under: ~/demo-marketplace/templates/python-webserver
  8. Add the following content to the config.yml file:

    name: PythonWebServer
    description: Simple Web Server with Python
    category: Programming
    version: 2.7
    
  9. Choose your own image (in PNG format) to use as a thumbnail for this application and use catalogIcon- as a prefix for the filename.
    The full filename looks like this: catalogIcon-python-webserver.png
  10. Save this image file under: ~/demo-marketplace/templates/python-webserver
  11. Create a 0 (zero)folder under: ~/demo-marketplace/templates/python-webserverThis folder enables installation script versioning. Other installation version scripts, such as 1,2, and 3, can be created.
  12. Create a readme.md file to describe the application under: ~/demo-marketplace/templates/python-webserver/0 
    Example readme content:
```
# Python WebServer
This template creates a simple webserver using Python

## Usage
Choose the HTTP port you want to expose, for example `8000`
```
  1. Create a docker-compose.yml file under: ~/demo-marketplace/templates/python-webserver/0
    Example content:
```
webserver:
  image: <your dockerhub <username>/python-webserver:latest
  ports:
    - ${HTTP_PORT}:8000
```
  1. Create a loop-compose.yml file under: 
    ~/demo-marketplace/templates/python-webserver/0
This `loop-compose.yml` file provides the variable descriptor for the `docker-compose.yml` file.

```
.catalog:
  name: Python-WebServer
  version: latest
  uuid: python-webserver—0
  questions:
  - variable: HTTP_PORT
    description: 'WebServer exposed port'
    label: 'Port:'
    required: true
    default: 8000
    type: int
```
  1. Push all files to the git repository.
```
$ ~/demo-marketplace> git add .
$ ~/demo-marketplace> git commit -m "add python webserver"
$ ~/demo-marketplace> git push -u origin master
```

Add a Docker Registry

To enable retrieval of applications from Docker containers, you first must give OT Link Platform access to the repository.

  1. In OT Link Platform, go to Applications > Registry.
  2. Enter the registry name, address, and credentials. Then, click Add.

Add a Custom Marketplace

In addition to the Default Marketplace, users can define their own public or private marketplaces. Typically, service providers and partners take advantage of this feature to deploy applications for their clients. Users can add multiple marketplaces and each marketplace can have multiple applications. The number of applications is limited only by the hardware size.

  1. Go to Applications > Configure.
  2. Click (plus) to add a custom marketplace.

  3. Enter a name,the relevant branch, and the Docker registry URL. For this example, use:
    1. Name: demo-marketplace
    2. Branch: master
    3. URL: /demo-marketplace
  4. Select a public or private marketplace. Then, click Add.

OT Link Platform will retrieve applications from this location and add the applications to the marketplace. This process may take some time because application data is retrieved over the network.

Once the marketplace is added, it will appear in the Marketplace List: Applications > Marketplace.