Skip to content

Remote Build Execution

This guide shows how to configure remote build execution (RBE) for your Bazel projects with the NativeLink Cloud. Before using this guide make sure you have followed our Bazel Quickstart.

Basic Configuration

To enable RBE all you need to do is add the below flag to your Bazel builds:

Terminal window
--remote_executor=grpcs://scheduler-YOUR_ACCOUNT_HERE.build-faster.nativelink.net:443

This will run your builds on a Ubuntu 22.04 image without any dependencies installed. For most users we don’t expect this to work out of the box as your project most likely depends on installations like GCC/Java/etc. To remedy that, continue with the instructions below to pass in your own images.

Custom Images

To support most RBE builds you will most likely need to pass in your own image with the correct toolchains installed to support your build. To use your own public image you can pass it using this configuration:

Terminal window
--remote_default_exec_properties="container-image=docker://public.ecr.aws/ubuntu/ubuntu:22.04_stable"

Or a public image on Docker Hub is accessible via:

Terminal window
--remote_default_exec_properties="container-image=docker://ubuntu:latest"

Private Images

If your images are in your own private repository, you can pass your repository credentials to allow us to pull your RBE images.

Terminal window
--remote_default_exec_properties="container-image=docker://123456789100.dkr.ecr.us-east-2.amazonaws.com/rbe-images:tag"
--remote_exec_header=x-nativelink-rbe-registry-server=123456789100.dkr.ecr.us-east-2.amazonaws.com
--remote_exec_header=x-nativelink-rbe-registry-username=AWS
--remote_exec_header=x-nativelink-rbe-registry-password="$(aws ecr get-login-password --region YOUR_REGION)"

Hermetic Bazel Builds

An alternative option to passing in your own custom image is using a fully hermetic Bazel build. This will allow you to use our default Ubuntu 22.04 image and your Bazel commands will install all needed dependencies.

You can see a sample of that in the WORKSPACE file of our Hermetic CC example repository here.

Bazel has many flags you can pass to it to modify RBE. We recommend three main flags to start.

--jobs

This is the number of concurrent jobs to run. We recommend starting with 50 but you can readily scale up to 200. Past this we recommend reaching out to us with help understanding your build and what optimal settings may be.

Terminal window
--jobs=200

--remote_download_minimal

This flag enables “Build Without Bytes” which means Bazel will skip downloading intermediate artifacts that aren’t necessary for your builds to complete. This can greatly increase the speed of your builds.

Terminal window
--remote_download_minimal

--remote_timeout

This is how long a job will run before timing out. The default is 60 seconds but we recommend setting 600.

Terminal window
--remote_timeout=600

Further configurations

You can see the rest of the Bazel command line arguments here, and don’t hesitate to reach out to us with any questions!

Execution Properties

You may have jobs that you need to configure to run on specific hardware, whether that’s GPUs or High Memory. In order to enable this, we utilize Bazel’s exec_properties. Inside a specific rule you can pass a node value that will map those tasks to the type of worker node you want to run your task on.

Terminal window
my_rule(
name = 'my_target',
exec_properties = {
'Pool': 'gpu-cuda'
}
)

To configure accepted values of Pool for your builds please reach out to us to get setup.