/bazel-distcache

[Experimental] Bazel Build Cache server

Primary LanguageGoApache License 2.0Apache-2.0

Bazel Build Distributed Cache

Go Report Card GoDoc Apache 2.0 License

A distributed build cache for Bazel declarative build system.

Why?!

Bazel is a great tool for having reproducible builds. However, if you run a large CI/CD pipeline using it, you end up rebuilding many artifacts over and over across different agents (or containers).

Bazel has experimental support for gRPC-based remote workers/caches.

The goal of the project is to leverage it and build:

  • localcache - local daemon that bazel talks to, providing low latency-first caching layer
  • distcache - remote server that localcache talks to in case it encounters a miss

Because Bazel supports hermetic builds, this cache will be usable for all languages and build targets: Java, C++, Go, Python, protobuf, Scala... you name it.

Status

This is pre-alpha, basically a localcache proof of concept. It works, and bazel happily uses it as a cache.

Usage:

localcache

To build:

go install github.com/mwitkow/bazel-distcache/cmd/localcache

To start:

bin/localcache --blobstore_ondisk_path=/tmp/localcache-blobstore

At this point an HTTP debug interface (including metrics) is running on http://localhost:10100. The default gRPC address for bazel is localhost:10101. You can use it for example:

bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build  --spawn_strategy=remote --remote_cache=localhost:10101 ...

Hacking Tips

License

bazel-distcache is released under the Apache 2.0 license. See the LICENSE file for details.