Tutorial: Creating Docker Images in Studio

This tutorial page describes how to use StreamBase Studio to build a runnable archive of a StreamBase Application, and automatically package that archive into a Docker container.

On this tutorial page, you will:

  • Configure a simple StreamBase Application.

  • Use StreamBase Studio to build a Docker-ready Image for that application.

  • Package this image into a Docker container managed locally in Docker Desktop.

Docker Desktop Requirements

To configure a StreamBase application for Docker, you must have:

  • StreamBase Studio.

  • A no-cost login on Docker Hub.

  • Docker Desktop for Mac or Windows installed, running, and logged into Docker Hub.

Note

When you obtain third-party software or services, it is your responsibility to ensure you understand the license terms associated with such third-party software or services and comply with such terms.

When configuring Docker Desktop, there is no need to enable the Kubernetes option at this point, but you can if you prefer.

Notes

The steps on this and the next few pages were tested in May, 2020 with release 2.3.0.2 of Docker Desktop for Windows and Docker Desktop for Mac, in both cases from the Stable release channel. Earlier releases of Docker Desktop and other Docker client solutions may work, but are explicitly not supported — including Docker Toolbox. Later releases of Docker Desktop are expected to work.

Docker Desktop for Windows requires 64-bit Windows 10 Pro or Enterprise with Microsoft Hyper-V available and enabled. Note that installing Hyper-V conflicts with VMware Workstation or Oracle VirtualBox on the same Windows computer, and the Docker Desktop installer disables those products if encountered. This is because Windows 10 allows only one virtualization hypervisor to run at the same time. See Docker's site for any further requirements of Docker Desktop for Windows.

Docker Desktop for Mac requires macOS 10.13 (High Sierra), 10.14 (Mojave), or 10.15 (Catalina). The Mac hardware must be a 2010 model or later. See Docker's site for any further requirements of Docker Desktop for Mac.

Load a Fragment Project

  1. From StreamBase Studio, select File>Import Samples and Community Content.

    In the search field for the StreamBase Sample Importer dialog, type first to narrow the list of options. Select the Getting Started Guide tutorial search result, then click Import Now.

  2. It may take some time for Studio to build the loaded project the first time, as it resolves and copies Maven dependencies. The project is ready when there are no red marks on any folder or file of the sample_firstap project in the Project Explorer view.

Maven-Install the Fragment

You must invoke Run As>Build... to build and install the fragment project before packaging the StreamBase Application project.

Note

This step is not required before packaging application projects for regular use without Docker. In that case, the packaging wizard, described in the next section, installs all dependent fragments as part of the packaging.

Follow these steps:

  1. In the Project Explorer view, select and right-click the sample_firstapp folder. Select Run As>Maven build...

    (Be sure to select the Maven build... option with the three dots. If you inadvertently run the other Maven build option and it fails, come back to this point and start over.)

  2. In the Edit Configuration and launch dialog:

    • In the Goals field, enter clean install

    • Select the Skip Tests and Resolve Workspace artifacts check boxes.

    • Click Apply, then click Run.

  3. Keep an eye on the Console view as messages scroll by. Look for the BUILD SUCCESS message.

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  4.980 s
    [INFO] Finished at: 2020-05-16T08:12:18-04:00
    [INFO] ------------------------------------------------------------------------
    

Create a StreamBase Application Project

The steps in this section create a StreamBase Application project with its Docker option enabled.

  1. Optional. Open the firstapp project's /src/main/eventflow folder to make a note of the Group ID used by the EventFlow fragment project, which is com.tibco.sb.sample.

  2. Select File>New>StreamBase Project.

  3. In the StreamBase Project dialog, enter a project name. This tutorial uses docker_1st throughout.

  4. Select the StreamBase Application option and click Next. (If you click Finish in error, start over.)

  5. In the Configure Maven Artifact panel, change the value of the Group ID to com.tibco.sb.sample to match the Group ID of the fragment sample as determined in step 1. (You are not required to use the same Group ID for an Application project as for its dependent fragment projects, but doing this brings clarity to the process.)

    Select the Enable Docker support check box. This is the entire difference between building an application that runs locally and one that runs in a Docker container.

    Optional. This tutorial suggests changing the Version number to 1.0.0 to save some typing with upcoming Docker commands, but that is not required.

    Click Next.

  6. Optional. Make changes In the Archetype Properties panel as needed, following the guidelines in the table below.

    Property Default Description
    description My Application Enter any text to characterize this application and distinguish it from other applications in your network. This string ends up in the <description> element of your application project's pom.xml file.
    testnodes A,B,C Specify one or more node names for test nodes that are started when you run Maven Test or another Maven goal that requires Test. You can reduce project build time at the expense of test coverage by replacing the default three nodes, A,B,C with just A.
    dockerDomain example.com Specify a domain name that will allow your Docker containers to communicate with each other. The domain name you specify here is configured into a TrustedHosts configuration file for this application. This allows all StreamBase Runtime nodes to participate in the same domain as the Docker containers, which allows node-to-node communication to occur without user authentication for nodes in the same Docker network. Members of this domain will be trusted hosts for each other.

    To take advantage of this feature, use the --network and --hostname options in your docker run command, as described in Configuring Multiple Docker Containers.

  7. Click Finish. (Also click OK if prompted with a follow-up dialog.)

    This creates a new project named docker_1st in the Project Explorer view.

Add Dependency

The next step is to configure docker_1st application project to be aware of its Maven dependency on the firstapp EventFlow fragment project.

  1. Select the docker_1st project name in the Project Explorer view. Right-click and select StreamBase>Manage Project Dependencies.

  2. Studio shows a message dialog like the following.

    When you click OK, Studio performs the following actions:

    • Opens the POM Editor for the application project's pom.xml file.

    • Switches to the Dependencies tab of the POM Editor.

    • Opens the Add Dependency dialog,

  3. In the Add Dependency Dialog, type firstapp in the Enter groupId filter field.

  4. Select com.tibco.sb.sample    firstapp in the Search Results field and open the arrowhead on its left.

    If there is more than one ep-eventflow-fragment entry (perhaps because your local Maven repository has artifacts from previous StreamBase releases), select the entry whose version number matches the current StreamBase release.

    Click OK.

  5. Confirm that the pom.xml file for the docker_1st project is saved.

Build the Docker Image

Build the Docker image as follows:

  1. Make sure your development machine is connected to the Internet. This procedure runs best with no settings.xml file in your local ~/.m2 directory, or with a minimal one.

  2. Important! Make sure your Docker for Windows or Docker for Mac installation is currently running, and that you are logged into Docker Hub.

  3. In the Project Explorer view, select and right-click the docker_1st folder. Select StreamBase>Create StreamBase Application Archive.

  4. This opens the Package an Application dialog.

  5. There is nothing to configure on this dialog (unless something went wrong in a previous run), so click Package Application.

  6. Keep an eye on the Output of packaging steps (which has the same content as the Console view) as messages scroll by. Look for one BUILD SUCCESS message for the fragment included in the application, plus a final BUILD SUCCESS message.

  7. To confirm success, open a StreamBase Command Prompt (Windows) or a StreamBase-configured Terminal window (macOS). Get a list of your currently installed Docker images using the docker images command:

    REPOSITORY   TAG      IMAGE ID         CREATED             SIZE
    deploy_1st   1.0.0    5dbddbadc3e1     23 minutes ago      1.02GB
    sbrt-base    10.6.0   c39719f31fba     2 hours ago         1.02GB
    centos       8        470671670cac     3 months ago        237MB
    

    Your images list may include other Docker images from running the Docker Getting Started tutorial, or from Kubernetes setup. The three images listed above are the ones generated by the Package Application dialog.

Next Steps

This concludes the work in StreamBase Studio to generate the StreamBase Application archive and package it into a Docker image in your local Docker environment.

The tutorial continues on the next page to demonstrate using Docker commands to run this image, and communicate with the containerized StreamBase application. Use the Next link on the bottom right below, or click Tutorial: Run and Manage with Docker Commands.