Bazel First-Time Setup¶
This document describes how to configure Bazel to connect to an EngFlow Remote Execution cluster.
1. Prepare a Docker container image for remote actions¶
Remote actions executed on Linux are executed in a Docker container to ensure a consistent execution environment. Your Docker container image must include all system dependencies of actions. For example, a C++ compiler may be required.
If there are no special requirements, Bazel toolchains project provides Ubuntu 16.04 base images.
You may want to add an engflow
user within your container. Linux builds are
executed with the UID 108. To register this user, add the snippet below
to your Dockerfile:
2. Create a remote configuration¶
In Bazel, a platform expresses an environment where an action can run. When performing remote execution, Bazel is instructed to build for a special EngFlow platform. This platform carries the Docker image and other environmental configuration to the remote execution service.
Once a Docker container is ready, use the rbe_configs_gen
tool
to generate Bazel configuration for the image. For example, the following will
generate configuration for a Ubuntu 20.04 image into a engflow_config
directory:
Bash | |
---|---|
rbe_configs_gen
generates a remote platform
target for EngFlow in
engflow_config/config/BUILD
. It also outputs configuration for the C++
toolchain in the container into engflow_config/cc/
.
If you already have a custom C++ compiler crosstool, it's likely easiest to
manually write the EngFlow platform rule rather than using
rbe_configs_gen
. Here is an example engflow_config/config/BUILD
for an
x86_64 Linux image:
BUILD | |
---|---|
"dockerNetwork": "standard"
to exec_properties
.
3. Set up .bazelrc
.¶
Configure Bazel to use the EngFlow platform in .bazelrc
.
-
Add common flags:
-
Add platform flags:
-
If not using a custom C++ toolchain already, add flags for the container's C++ toolchain:
-
If Java is required, optionally use the hermetic JDK shipped with Bazel:
.bazelrc -
Add the remote executor flags. For the
<CLUSTER_ENDPOINT>
, use the host name or IP address of the Load Balancer. You may also have to specify the port, if using a non-standard one. The default ports are 443 for grpc/s, and 80 for http/s.If you use TLS with our certificate (
engflow-ca.crt
):
Usage¶
We recommend using the latest available Bazel version.
Bash | |
---|---|