Configuring your pipeline to build new Docker images
Docker can build new images by reading instructions from a Dockerfile. Prepare a
Dockerfile to take a base Docker image and add code from your customization package to create a new
Docker image.
Before you begin
- Ensure that Docker is installed.
- Build the customization package that includes the custom assets.
Procedure
Create a script that can be used by your pipeline to complete the following
steps.
- Pull the latest customized package from the artifact repository and extract the package to a folder called CusDeploy.
- Create a Dockerfile on the same level as the CusDeploy folder.
-
Add the following text to the Dockerfile and update with your values.
FROM docker_url/library/source_image_name:source_image_tag COPY CusDeploy /SETUP/Cus RUN /SETUP/bin/applyCustomization.sh <other_RunEngine_commands>
- docker_url
- The Docker repository hostname where to get the source image.
- library
- The path to your source image in the repository.
- source_image_name
- The name of the source image. For example, ts-app, ts-web, crs-app, search-app, xc-app.
- source_image_tag
- The tag of the source image that you want to use.
- other_RunEngine_commands
- (Optional) You can specify commands to configure the application inside the Docker image. For example, you can add commands to set the data source so that the application can connect to your database. For more information about Run Engine commands, see Run Engine commands.
- The FROM argument specifies which base Docker image to update.
- The RUN argument references a shell script that instructs Docker how to apply the customization package to the base image.
For example,FROM myDockerRegisty.com/commerce/ts-app:latest COPY CusDeploy /SETUP/Cus RUN /SETUP/bin/applyCustomization.sh
-
Build the new Docker image.
For example, run the following command.
You most likely want to keep the <target_image_name> the same as the source_image_name. Depending how you want to maintain your Docker images in the repository, you might want to also use the same tag, or specify a unique tag such as the timestamp of the build.docker build -t <target_image_name>:<tag>
- Repeat steps 2 to 4 for the other Docker images that you need to update.
- Push the new Docker images to your Docker repository.