For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build custom delegate images using Dockerfile

This topic describes how to build custom delegate images using the Harness Delegate Dockerfile.

You can use the Harness Delegate Dockerfile to build custom delegate images. The Dockerfile is available in the delegate Dockerfile repository.

The repository includes the Dockerfile-minimal and Dockerfile-ubuntu versions.

NOTE

If you build and use custom images, you can choose to enable or disable automatic upgrades for Kubernetes delegates. To learn more about automatic upgrades with custom images, go to Use automatic upgrade with custom delegate images.

For more information on delegate automatic upgrades and the delegate expiration policy, go to Delegate automatic upgrades and expiration policy.

Dockerfile tools

You can include third party tools with your delegate when you use the delegate Dockerfile. The image includes default tools. For a list of default tools and their versions, go to the delegate Dockerfile repository.

NOTE

While building custom delegate if you are not using delegate as base image example then please ensure that you always package scm binary like below

RUN mkdir -m 777 -p client-tools/scm/<SCM_VERSION> \
  && curl -f -s -L -o client-tools/scm/<SCM_VERSION>/scm https://app.harness.io/public/shared/tools/scm/release/<SCM_VERSION>/bin/linux/$TARGETARCH/scm

SCM_VERSION should be coming from our delegate to scm version mapping

Example: If you're using delegate version 24.08.83705 then you should use scm version a81c96813, which gives below command

mkdir -m 777 -p client-tools/scm/a81c96813 \
  && curl -f -s -L -o client-tools/scm/a81c96813/scm https://app.harness.io/public/shared/tools/scm/release/a81c96813/bin/linux/$TARGETARCH/scm 

Dockerfile-minimal

Use Dockerfile-minimal to create delegate images without tools. This image includes only the SCM client tool.

Dockerfile-ubuntu

Use Dockerfile-ubuntu to create Ubuntu-based delegate images. This image includes all the same tools as the default Dockerfile.

NOTE

You can also replace the existing tools with your preferred CI/CD tools.

Build the image

To build the image, you need two arguments:

  1. TARGETARCH (amd64/arm64)

  2. The delegate build version

The build version to use for your account is available in the Harness API documentation.

To learn about delegate version support expiration, go to Delegate expiration policy.

Here is an example script to get the version, which uses curl to fetch and jq to parse:

To build your custom image, use the build_version from above and the applicable command below:

Dockerfile

Dockerfile-minimal

Build a custom image with non-root access that includes custom certificates

If the delegate cannot run the delegate container as a root user but requires a custom CA, you can add custom CA bundle files to the delegate image and run a load_certificates.sh script on the files.

The load_certificates.sh script ensures that your CA certificates are:

  • Added to the delegate's Java truststore located at $JAVA_HOME/lib/security/cacerts.

  • Added to the Red Hat OS trust store.

  • Applied to Harness CI, STO, and delegate pipelines.

To build your custom delegate image, do the following:

  1. Add all of your CA certificates to a local directory.

  2. Add the lines below to your delegate Dockerfile after the RUN curl -s -L -o delegate.jar $BASEURL/$DELEGATEVERSION/delegate.jar line and before the USER 1001 line because root access is required to run the script. Replace the directory paths with your local directory locations.

    This copies all the certificates from the local ./my-custom-ca directory to /opt/harness-delegate/my-ca-bundle/ directory inside the container.

    WARNING

    Don't copy your certificates to the folder /opt/harness-delegate/ca-bundle folder. This folder is reserved for storing additional certificates to install the delegate. For more information, go to Install with custom certificates.

    Set the user to root before you run the load_certificates.sh script. Then set the user back to normal access after you run the script.

  3. Run the load_certificates.sh script.

  4. Build your custom image.

Examples

You can use the released delegate image as your base image. You can also use OS images like UBI or Ubuntu as a base to build a delegate image with custom certs.

Use the released delegate image

Use a UBI base image

Last updated

Was this helpful?