Run WSO2 Micro Integrator on Docker

To run your Micro Integrator solutions on Docker or Kubernetes, you need to first create an immutable docker image with the required synapse artifacts, configurations, and third-party dependencies by using the base Docker image of WSO2 Micro Integrator. You can then deploy and run the immutable images on Docker or Kubernetes. One advantage of having an immutable docker image is that you can easily implement a CI/CD pipeline to systematically test the solution before deploying in production.

Base Docker Images

Two types of base Docker images are available for the Micro Integrator:

  • The Micro Integrator Docker image (with the latest updates) is available in the WSO2 Docker Registry.

    Note that you need a valid WSO2 subscription to use the Docker image with updates. Therefore, you need to provide your log in credentials when downloading the Docker image. If you do not already have a subscription, you can get a free trial subscription.

    Micro Integrator Docker image (with updates)

    docker.wso2.com/wso2mi:1.0.0

    Log in to WSO2 Docker Registry

    docker login docker.wso2.com
  • The community version of WSO2 Micro Integrator's base Docker image is available on DockerHub.

    Base Docker Image and Tag (community version)

    wso2/wso2mi:1.0.0
    The wso2mi:latest tag points to the most lightweight version of the Micro Integrator, which includes the minimal Docker image based on Alpine Linux.

    Go to DockerHub to find the Micro Integrator Docker images that are based on Ubuntu and CentOS platforms.

Run on Docker using WSO2 Integration Studio

Let's create a Docker project for an integration solution and run it on a Docker container. You will use WSO2 Integration Studio and the base Docker image of the Micro Integrator for this process.

  1. Create a proxy service with the following configuration:

    • Synapse configuration

      <?xml version="1.0" encoding="UTF-8"?>
      <proxy name="HelloWorld" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
          <target>
              <inSequence>
                  <payloadFactory media-type="json">
                      <format>{"Hello":"World"}</format>
                      <args/>
                  </payloadFactory>
                  <respond/>
              </inSequence>
              <outSequence/>
              <faultSequence/>
          </target>
      </proxy>
    • Graphical view Sample Proxy Service

  2. You can now create a Docker project that includes the Synapse configuration given above.

  3. Use the following details:

    Target Repository : sampleproxy
    Target Tag : 1.0.0

  4. Execute the following command:

    docker image ls

    The list of currently available Docker images are displayed in the terminal similar to the example given below. The Docker image you created is included in this list as shown below.

    REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
    sampleproxy             1.0.0               49092809b36a        10 minutes ago      315MB
    wso2/wso2mi             latest              088477c689f6        2 days ago          315MB
  5. Start the container with the following command:

    docker run -d -p 8290:8290 sampleproxy:1.0.0

    If you want to use the micro integrator dashboard for monitoring, use following docker command:

    docker run -p 8290:8290 -p 9164:9164 -e   JAVA_OPTS="-DenableManagementApi=true" sampleproxy:1.0.0
  6. Invoke the proxy service as follows:

    curl http://localhost:8290/services/HelloWorld -XGET

    You will see the following response:

    {"Hello":"World"}

Create Docker files manually

If you already have packaged integration artifacts in a CAR file, you can manually create the Docker files and deploy on Docker. Follow the steps given below.

Tip

Before you begin: Use WSO2 Integration Studio to create the integration artifacts and then export the integration artifacts into a CAR file.

  1. Create the Dockerfile as shown below. This file contains instructions to download the base Docker image of WSO2 Micro Integrator from DockerHub (community version) or the WSO2 Docker Registry (includes updates), and to copy the integration artifacts to the Micro Integrator.

    The Dockerfile:

    FROM <docker_image_name>:1.1.0
    COPY <directoy_path>/<capp_name> $WSO2_SERVER_HOME/repository/deployment/server/carbonapps
    The information specified in the Docker file is as follows:

    Parameter Description
    FROM

    The 'FROM' tag in the docker file specifies the WSO2 Micro Integrator version that should be downloaded. You can use the updated Docker image or the community version as shown below. The version is 1.1.0 of the WSO2 Micro Integrator. If required, you can use an earlier version by replacing 'latest' with the version number.

    Example 1: Docker image with updates
    FROM docker.wso2.com/wso2mi:1.1.0
    Example 2: Docker image without updates (community version)
    FROM wso2/wso2mi:1.1.0
    COPY

    The 'COPY' tag in the docker file specifies the directory path to your composite application, followed by the location in your Docker instance to which the composite application should be copied. The location of MI_HOME can be referred to as 'WSO2_SERVER_HOME' since this is exposed as an environment variable from the base image.

    Example 1
    COPY carbonapps $WSO2_SERVER_HOME/repository/deployment/server/carbonapps

    If you have multiple composite application that you want to deploy in Docker using a single Docker image, add another entry to the Dockerfile. For example:

    Example 2
    COPY carbonapps $WSO2_SERVER_HOME/repository/deployment/server/carbonapps
    COPY <sample_carbon_app> $WSO2_SERVER_HOME/repository/deployment/server/carbonapps

  2. Create an immutable Docker image for your integration artifacts on WSO2 Micro Integrator by executing the following command from the location of your Dockerfile.

    docker build -t sample_docker_image .
  3. Start a Docker container by running the Docker image as shown below.

    docker run -d -p 8290:8290 sample_docker_image
Top