Defining customized logic with run engine commands and extension points

In this lesson, you define customized Docker start-up logic with run engine commands and extension points.

Before you begin

Before you customize Docker start-up logic using run engine commands, follow the instruction in Creating your own Run Engine commands to define your own run engine commands.

About this task

This method defines the customized logic in run engine commands and execute the commands through extension points. The run engine commands define how to customize the logic and the extension points define when to customize the logic.

In this lesson, suppose we have created a run engine command named cus-command-name. To deploy run engine commands:

Procedure

  1. Create a new cus folder in the local environment.
  2. Create a preConfigure.sh file in the local folder with the following code lines:
    #!/bin/bash
    wget -O '/SETUP/ run-engine-cus.zip' "http://nexusServer:8081/nexus/service/local/artifact/maven/redirect?r=snapshots&g=run-engine-cus&a= run-engine-cus &v=@version@&p=zip" && \
    unzip /SETUP/crs-app-cus.zip -d /SETUP/
  3. Create a custConfiguration.sh file in the local folder with the following code lines:
    #!/bin/bash
          Run cus-command-name <parameter1>  <parameter2>
          Run OOTB-command-name <parameter1>  <parameter2>
    
    In this command, cus-command-name is the customized run engine command you created; OOTB-command-name is the pre-defined run engine command.
  4. Create a Docker file with the following code lines:
    FROM docker-repo/commerce/crs-app:tag
    COPY preConfigure.sh /SETUP/bin/
    COPY custConfiguration.sh /SETUP/bin
    
  5. Build the custom Docker image:
    docker build -t docker-repo/commerce/crs-app:cus

Results

You have customized the Docker start-up logic with run engine commends.
Lessons Learned

Customizing Docker images with run engine command is very flexible. You only need to define what you want to do in preconfigure.sh and custConfiguration.sh. When the container is created and started, the container will execute the commands.