Creating Docker Images for IBM Control Desk Components on Admin Workstation

This topic describes how to create Docker Images for IBM Control Desk Components on Admin Workstation.

Before you begin

Before creating an IBM Control Desk container image, ensure that the prerequisites mentioned earlier are in place. As given in the Admin Workstation section, a separate container image needs to be built for each workload. The process of building a container image is the same for 5 workloads. The only thing that differs is the configuration and code that is specific to the workload.

Procedure

  1. Configure files needed for building workload bundles:
    1. Every workload of the IBM Control Desk runs within the WebSphere Liberty runtime and requires application bundles to be created. These application bundles are created based on Java™ EE specification, and depending on the workload, it will be a Web Application Archive file (.war file) or an Enterprise Application Archive file (.ear file). WebSphere Liberty runtime understands the bundles and loads the code to run based on a set of deployment descriptor files. These deployment descriptor files are typically in XML file format and are in different folders depending on the archive type. For ease of use, the deployment descriptors needed for building the workload bundles are put in the deployment/was-liberty-default/config-deployment-descriptors folder. Make sure to edit the files in this folder instead of the files in the applications\maximo folders.
    2. Because the requirements of each workload vary, the configuration of WebSphere Liberty runtime that is used for running the workload also varies. The WebSphere Liberty runtime can be configured with a set of files (server.xml, jvm.options, certificates, etc.) that are used to initialize the environment. These files are, by default, included for each workload in the deployment\was-liberty-default\config-servers folder. Edit these files before building the application bundles to ensure that the final container image has the appropriate configuration ready to run the workload.
  2. Build the application bundle needed for the IBM Control Desk workload:
    1. Open a Command Prompt or Terminal and change to the deployment/was-liberty-default folder.
    2. Run the appropriate command to build the workload bundles (Java EE war/ear files). For example, to build the icd-ui workload, run the buildmaximoui-war and buildmaximo-xwar commands.
      Note: In case of issues during script file execution, execute the commands in the script file manually.
    3. The workload bundles are created in the deployment/was-liberty-default/deployment/maximo-ui/maximo-ui-server/apps folder. The commands also copy the workload deployment descriptor files for the workload from the deployment/was-liberty-default/config-deployment-descriptors subfolder into the deployment/was-liberty-default/deployment/. Note that the maximo-ui subfolder created under deployment/was-libertydefault/deployment/ folder is treated as a workload deployment folder, which will be used to create the container image. For each workload, a separate folder is created to distinguish the content associated with the workload.
  3. Build the container image needed for the IBM Control Desk workload:
    1. After the application bundle needed for the IBM Control Desk workload is built, a container image can be created that can be deployed into a Kubernetes runtime.
    2. To create the container image, a Docker file needs to be created containing instructions about the contents of the image. Since the workload is going to be based on the WebSphere Liberty runtime, a base image of WebSphere Liberty is needed. This image can be obtained from the Docker hub. This base image can be extended to create a new image that includes the configuration and application bundle needed for the workload.
    3. To create the container image on a workstation, Docker must be installed and running on the machine where the container images need to be built.
    4. To create the container images on the administration workstation, create a folder from where the docker images are going to be built, for example, if using windows, c:\icd-docker-files. In this folder, create a subfolder icd-base. Create two sub-directories inside icd-base, files, and bin. Copy the jvm.options file inside the files sub-directory and create a new file entrypoint.sh inside bin sub-directory. The purpose of the entrypoint.sh is to check connections with database and jvm before starting the websphere server. Refer the contents of the entrypoint.sh below:
      SLEEP_TIME=5
      TIMEOUT=300
      
      # if the db host, port and name have been specified the script waits for
      # the port open on the host
      if [ -n "$DB_HOST" -a -n "$DB_PORT" -a -n "$DATABASE" ]; then
        if [ ! which nc &>/dev/null ]; then
          echo "ERROR: nc command not installed" >&2
          exit 255
        fi
      
        t=0
        # wait loop
        nc -z $DB_HOST $DB_PORT
        while [ $? -ne 0 -a $t -le $TIMEOUT ]; do
          echo "port $DB_PORT is not open on $DB_HOST, sleep $SLEEP_TIME seconds and retry"
          sleep $SLEEP_TIME
          t=$(( $t + $SLEEP_TIME ))
          nc -z $DB_HOST $DB_PORT
        done
      
        if [ $t -gt $TIMEOUT ]; then
          echo "ERROR: port $DB_PORT not open on $DB_HOST within $TIMEOUT seconds"
          exit 1
        fi
      export JVM_ARGS="$JVM_ARGS -Dmxe.db.url=jdbc:db2://${DB_HOST}:${DB_PORT}/${DATABASE}"
      fi
      
      if [ -n "$JMS_SERVER" -a -n "$JMS_PORT" ]; then
        export JVM_ARGS="$JVM_ARGS -Djms.server=${JMS_SERVER} -Djms.port=${JMS_PORT}"
      fi
      .  /opt/ibm/helpers/runtime/docker-server.sh
      
    5. Go to c:\icd-docker-files\icd-base and create a DockerFile for icd base container. Below are the contents:
      FROM websphere-liberty
      # copy jvm.options file
      COPY files/jvm.options /opt/ibm/wlp/usr/servers/defaultServer/
      
      # copy new entrypoint
      COPY bin/entrypoint.sh  /
      ENTRYPOINT [ "/entrypoint.sh" ]
      CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
      
      
      The base image here is websphere-liberty with latest tag. The entrypoint.sh is defined as the ENTRYPOINT of the image.
    6. Build the icd base docker image by using docker build command.
      docker build -t icd:base.
      This image will act as a base for 5 IBM Control Desk components (UI, MEA, API, CRON, REPORT).
    7. Create the images for components. Go to c:\icd-docker-files and create a subfolder for each workload. For example, for the IBM Control Desk UI, create a folder called icd-ui. Note that the icd-ui workload includes two bundle files (maximoui.war and maximo-x.war file). In each of the workload subfolders, create another subfolder called maximo-ui-server.
    8. Copy the IBM Control Desk application bundles and associated files for the workload from the workload deployment folder into the maximo-ui-server folder.

      For example:

      Copy all files and sub-directories from <maximo install folder>\deployment\was-liberty-default\deployment\maximo-ui to c:\icd-docker-files\icd-ui\maximo-ui-server.

    9. Create a sub-directory files in c:\icd-docker-files\icd-ui\maximo-ui-server and copy jvm.options and server.xml in this directory. This step allows you to change the configurations during image creation and overrides the configuration done at time of war/ear file creation.
    10. Create a file named Dockerfile in the workload folder (for example, c:\icd-docker-files\icd-ui\maximo-ui-server) that contains the following content:
      FROM icd:base
      USER root
      
      # environment variables
      ENV DB_HOST localhost
      ENV DB_PORT 50005
      ENV DATABASE maxdb76
      
      # copy the server.xml and jvm.options files
      COPY files/server.xml /opt/ibm/wlp/usr/servers/defaultServer/
      COPY files/jvm.options /opt/ibm/wlp/usr/servers/defaultServer/
      
      # install the additional utilities
      RUN ["/opt/ibm/wlp/bin/installUtility","install","defaultServer"]
      
      # copy the application
      COPY --chown=default:root apps /opt/ibm/wlp/usr/servers/defaultServer/apps 
      
      The content in this file is indicating to the Docker build tool to use the icd base image as the base image.
      Note: Note that the content of this file must be changed based on the workload deployment. In the example, IBM Control Desk UI bundles are used.
    11. Run the Docker build command to build the image. For example, the following command uses the Dockerfile from the current directory, builds an image, and tags the image with the <icd>/<ui>:<7612>. The first part of the tag is the namespace name (icd) followed by the tag name (ui) and ends with a version number (7612). Always use this tag naming convention to ensure that it is easy to identify the image of the workload. For example, for the ui workload, run the following command:
      docker build -t icd/ui:<7612>

      After the command is successfully run, it will create an image based on the Dockerfile, and the image is put into the local Docker image registry. Verify that the image exists in the local registry using the docker image ls command, which must list all the images available including the new one.

    Note: You can apply LAfix in admin workstation and create the images to deploy in your kubernetes cluster. This way you can apply LAfix on your Container environment.