1*c8dee2aaSAndroid Build Coastguard WorkerRBE configurations 2*c8dee2aaSAndroid Build Coastguard Worker================== 3*c8dee2aaSAndroid Build Coastguard Worker 4*c8dee2aaSAndroid Build Coastguard WorkerSome subdirectories of this folder are generated. For example, `gce_linux` was generated by running 5*c8dee2aaSAndroid Build Coastguard Worker`make generate_linux_config`. Those generated files describe the C++ and Java toolchain that are 6*c8dee2aaSAndroid Build Coastguard Workerin the RBE Docker image; these toolchains are required to run Bazel, but are **not** the toolchains 7*c8dee2aaSAndroid Build Coastguard Workerthat we use to compile our code. 8*c8dee2aaSAndroid Build Coastguard Worker 9*c8dee2aaSAndroid Build Coastguard WorkerWe build our own, bare-bones, Docker image to use on RBE. We intend to use a hermetic toolchain 10*c8dee2aaSAndroid Build Coastguard Worker(see //toolchain) that specifies everything necessary to compile and link Skia. Use of the 11*c8dee2aaSAndroid Build Coastguard Workerhermetic toolchain on and off RBE makes the build reproducible and consistent across machines, 12*c8dee2aaSAndroid Build Coastguard Workerand not require internet access (assuming the toolchain has been cached at least once). This setup 13*c8dee2aaSAndroid Build Coastguard Workerhas the desirable property of not needing to change and upload RBE Docker images if we need to 14*c8dee2aaSAndroid Build Coastguard Workerchange a small detail of our toolchain. 15*c8dee2aaSAndroid Build Coastguard Worker 16*c8dee2aaSAndroid Build Coastguard WorkerThe only requirement we have of our Docker image (beyond the minimum requirements to run Bazel) 17*c8dee2aaSAndroid Build Coastguard Workerare that it have sufficient runtime libraries to run our toolchain. For example, this means that 18*c8dee2aaSAndroid Build Coastguard Workerthe Linux RBE image has at least glibc 2.32, which is the current minimum requirement of the 19*c8dee2aaSAndroid Build Coastguard WorkerLinux binaries in our toolchain. This is the same requirement of any developer who tries to 20*c8dee2aaSAndroid Build Coastguard Workerbuild Skia using Bazel locally. 21*c8dee2aaSAndroid Build Coastguard Worker 22*c8dee2aaSAndroid Build Coastguard WorkerGetting rbe_configs_gen 23*c8dee2aaSAndroid Build Coastguard Worker----------------------- 24*c8dee2aaSAndroid Build Coastguard WorkerIt is suggested to download a prebuilt binary from 25*c8dee2aaSAndroid Build Coastguard Worker[GitHub](https://github.com/bazelbuild/bazel-toolchains/releases/tag/v5.1.1) and put that onto 26*c8dee2aaSAndroid Build Coastguard Workeryour PATH. 27*c8dee2aaSAndroid Build Coastguard Worker 28*c8dee2aaSAndroid Build Coastguard WorkerCreating/Updating the RBE image 29*c8dee2aaSAndroid Build Coastguard Worker------------------------------- 30*c8dee2aaSAndroid Build Coastguard WorkerIn accordance with SLSA level 1, we want to be able to have a scripted way of building our image 31*c8dee2aaSAndroid Build Coastguard Workerand specify exactly what artifacts are in it. To accommodate this, we specify the exact sha256 32*c8dee2aaSAndroid Build Coastguard Workerhash of the base Docker image we use and the exact versions of the packages we install on top of 33*c8dee2aaSAndroid Build Coastguard Workerthat. If we need to add a package or update things, it is best build the image without these 34*c8dee2aaSAndroid Build Coastguard Workerqualifiers to see what was actually used, and then respecify them so if someone were to build 35*c8dee2aaSAndroid Build Coastguard Workerthe docker image again, they are likely to get the same image. 36*c8dee2aaSAndroid Build Coastguard Worker 37*c8dee2aaSAndroid Build Coastguard WorkerThis process is: 38*c8dee2aaSAndroid Build Coastguard Worker 1) Modify the appropriate Dockerfile (e.g. gce_linux_container/Dockerfile) to not have the 39*c8dee2aaSAndroid Build Coastguard Worker version or hash qualifiers. Also increment the appropriate VERSION variable in `Makefile`. 40*c8dee2aaSAndroid Build Coastguard Worker 2) Add any new packages or make any changes. 41*c8dee2aaSAndroid Build Coastguard Worker 3) Run `make build_linux_container` to build the image locally. One may verify it works by running 42*c8dee2aaSAndroid Build Coastguard Worker something like `docker run -it gcr.io/skia-public/rbe_linux:v3 /bin/bash`. 43*c8dee2aaSAndroid Build Coastguard Worker 4) Note the versions and base image hash that were used. Modify the Dockerfile to use these. 44*c8dee2aaSAndroid Build Coastguard Worker 1) `docker pull debian:bookworm-slim` is the easiest way to see the sha256 and get the latest. 45*c8dee2aaSAndroid Build Coastguard Worker 2) Versions can be found looking for logs like: 46*c8dee2aaSAndroid Build Coastguard Worker `Get:89 http://deb.debian.org/debian bookworm/main amd64 clang amd64 1:14.0-55.2+b1 [9976 B]` 47*c8dee2aaSAndroid Build Coastguard Worker 5) Run `make push_linux_container` to rebuild the container and push it to GCS where it can 48*c8dee2aaSAndroid Build Coastguard Worker be used by our RBE workers. Note the sha256 hash of this created container 49*c8dee2aaSAndroid Build Coastguard Worker 6) Modify the appropriate generate step in `Makefile` (e.g. `generate_linux_config`) to refer 50*c8dee2aaSAndroid Build Coastguard Worker to the correct toolchain_container. Then, run that step. 51*c8dee2aaSAndroid Build Coastguard Worker 7) Modify the RBE platform in `//platform/BUILD.bazel` to refer to the new `container_image`. 52*c8dee2aaSAndroid Build Coastguard Worker 53*c8dee2aaSAndroid Build Coastguard WorkerWe chose not to use Bazel rules for this container step, as that could be difficult to bootstrap 54*c8dee2aaSAndroid Build Coastguard Workerwithout Bazel already setup. Additionally, Make is a simple and sufficient way to script the steps 55*c8dee2aaSAndroid Build Coastguard Workerfor SLSA purposes. 56*c8dee2aaSAndroid Build Coastguard Worker 57*c8dee2aaSAndroid Build Coastguard WorkerDefining our own Bazel RBE platforms 58*c8dee2aaSAndroid Build Coastguard Worker------------------------------------ 59*c8dee2aaSAndroid Build Coastguard WorkerWhile the generated files *do* have a platform we can use (e.g. 60*c8dee2aaSAndroid Build Coastguard Worker`//bazel/rbe/gce_linux/config:platform`), we do not use it because we cannot easily customize it 61*c8dee2aaSAndroid Build Coastguard Workerwithout a risk that the changes will be lost when we update the image. Thankfully, we can specify 62*c8dee2aaSAndroid Build Coastguard Workerour own platforms, which we do in `//bazel/platform`, which is where we put the exec_properties 63*c8dee2aaSAndroid Build Coastguard Workerneeded to use our RBE instances. 64*c8dee2aaSAndroid Build Coastguard Worker 65*c8dee2aaSAndroid Build Coastguard WorkerMore details 66*c8dee2aaSAndroid Build Coastguard Worker------------ 67*c8dee2aaSAndroid Build Coastguard Workerhttps://docs.google.com/document/d/14xMZCKews69SSTfULhE8HDUzT5XvPwZ4CvRufEvcZ74/edit 68*c8dee2aaSAndroid Build Coastguard Worker 69*c8dee2aaSAndroid Build Coastguard WorkerRBE Metrics 70*c8dee2aaSAndroid Build Coastguard Worker----------- 71*c8dee2aaSAndroid Build Coastguard Workerhttp://go/skia-rbe-metrics 72