Skip to main content

Set up a local runner build infrastructure

You can define a CI build infrastructure on a Linux, macOS, or Windows host by installing a Harness Delegate and local Drone Runner. When the pipeline runs, the Drone Runners runs the build actions in the environment where it is installed. The Delegate handles communication between Harness and the Drone Runner.

Local runner build infrastructure is recommended for small, limited builds, such as a one-off build on your local machine. Consider other build infrastructure options for builds-at-scale.

The Docker Delegate is limited by the total amount of memory and CPU on the local host. Builds can fail if the host runs out of CPU or memory when running multiple builds. The Docker Delegate has the following system requirements:

  • Default 0.5 CPU.
  • Default 1.5GB. Ensure that you provide the minimum memory for the Delegate and enough memory for the host/node system.

Install the Delegate

Use the following modifications along with the Docker environment instructions in Install a Delegate:

  • Add --net=host to the first line.
  • Add -e DELEGATE_TAGS="<delegate-tag>". Use the tag for your Docker environment's architecture: linux-amd64 or linux-arm64.

Here's an example of an install script for Linux arm64:

docker run --cpus=1 --memory=2g --net=host \
-e DELEGATE_NAME=docker-delegate \
-e NEXT_GEN="true" \
-e DELEGATE_TYPE="DOCKER" \
-e ACCOUNT_ID=H5W8iol5TNWc4G9h5A2MXg \
-e DELEGATE_TOKEN=ZWYzMjFmMzNlN2YxMTExNzNmNjk0NDAxOTBhZTUyYzU= \
-e LOG_STREAMING_SERVICE_URL=https://app.harness.io harness/log-service/ \
-e DELEGATE_TAGS="linux-arm64" \
-e MANAGER_HOST_AND_PORT=https://app.harness.io harness/delegate:23.02.78306

Make sure to create the Delegate at the appropriate scope, such as the project level or account level.

Install the Drone Runner

The Drone Runner service performs the build work. The Delegate needs the Runner to run CI builds.

  1. Download a Drone Runner executable corresponding to your build farm's OS and architecture.

  2. To use self-signed certificates, export CI_MOUNT_VOLUMES along with a comma-separated list of source paths and destination paths formatted as path/to/source:path/to/destination, for example:

    export CI_MOUNT_VOLUMES="[path/to/local/cert]:/etc/ssl/certs/ca-certificates.crt,[path/to/local/cert2]:/etc/ssl/certs/cacerts.pem"
  3. Enable execution permissions for the Runner. For example:

    sudo chmod +x drone-docker-runner-linux-arm64
  4. Start the runner binary. For example:

    sudo ./drone-docker-runner-linux-arm64 server

Here is an example of the three commands to install the Linux arm64 Drone Runner with self-signed certificates:

export CI_MOUNT_VOLUMES="[path/to/local/cert]:/etc/ssl/certs/cacerts.pem"
sudo chmod +x drone-docker-runner-linux-arm64
./drone-docker-runner-linux-arm64 server

Set the pipeline's build infrastructure

Update the pipeline where you want to use the Docker Delegate. You can use either the Visual or YAML pipeline editor.

  1. In the pipeline's Build stage, select the Infrastructure tab.
  2. Select Local for the Infrastructure.
  3. Select the relevant Operating System and Architecture.
  4. Save your pipeline.

Troubleshooting

The Delegate should connect to your instance after you finish the installation workflow above. If the Delegate does not connect after a few minutes, run the following commands to check the status:

docker ps
docker logs --follow <docker-delegate-container-id>

The container ID should be the container with image name harness/delegate:latest.

Successful setup is indicated by a message such as Finished downloading delegate jar version 1.0.77221-000 in 168 seconds.