Defining customized logic with Dockerfile

In this lesson, you define all customized Docker start-up logic in Dockerfile.

About this task

The most straightforward way is to define everything in your custom Docker file. It means before the Docker container is created, prepare all customization packages and configuration files needed. The following procedure is an example of how to do the customization.

The example copies the customized package to the Liberty server rootdirectory, modifies a configuration file (jvm.option), and outputs a custom Docker image.

Procedure

  1. Create a new cus folder in the local environment.
  2. Copy the customization package crs-app-cus.zip to the new folder. This ZIP file includes javaagent.jar and config.yaml.
  3. Create a Dockerfile to copy the customization package to the custom Docker and to update the jvm.option file.
    Here is a sample Dockerfile:
    FROM docker-repo/commerce/crs-app:tag
    COPY crs-app-cus.zip /opt/WebSphere/Liberty/usr/servers/default/
    RUN unzip /opt/WebSphere/Liberty/usr/servers/default/crs-app-cus.zip -d /opt/WebSphere/Liberty/usr/servers/default/ && \
             sed -i '$a\-javaagent:./ javaagent.jar=8080:config.yaml' /opt/WebSphere/Liberty/usr/servers/default/jvm.options
    
  4. Build the customized Docker image with the following command:
    docker build -t docker-repo/commerce/crs-app:cus

Results

You have successfully defined all customized Docker start-up logic in Dockerfile.
Lesson checkpoint

In this lesson, you learned how to set HCL Commerce to follow the predefined Docker container start up logic for HCL Commerce Version 9.1 to start the Docker.

Lessons Learned
However, the predefined logic includes the following drawbacks:
  • Because the customization package is cumulative, when its size grows, the size of the docker image also grows.
  • If you want to copy and modify other configuration files, you need to modify the Docker file as well. This caused extra effort.
Continue with the following lessons on how to customize Docker start-up logic with extention points or run engine commands.