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.
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.
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.
Build the image
To build the image, you need two arguments:
TARGETARCH (amd64/arm64)
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:
Add all of your CA certificates to a local directory.
Add the lines below to your delegate Dockerfile after the
RUN curl -s -L -o delegate.jar $BASEURL/$DELEGATEVERSION/delegate.jarline and before theUSER 1001line 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-cadirectory to/opt/harness-delegate/my-ca-bundle/directory inside the container.Run the
load_certificates.shscript.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?