Skip to content

Bazel

What is Bazel – Tutorial, Examples, and Advantages

Bazel is an open-source build tool developed by Google to automate build processes for large-scale software. Companies such as Pinterest, Adobe, SpaceX, Nvidia, and LinkedIn use it, amongst others. In this tutorial, you’ll understand what Bazel is, how it works, and its important benefits. You’ll also learn how you can generate Bazel builds for your monorepo project.

How to install Bazel on Ubuntu

Step 1: Add Bazel distribution URI as a package source

# Setup package source
$ sudo apt install apt-transport-https curl gnupg -y
$ curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg
$ sudo mv bazel-archive-keyring.gpg /usr/share/keyrings
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list

Step 2: Install and update Bazel

$ sudo apt update && sudo apt install bazel

Once installed, you can upgrade to a newer version of Bazel as part of your normal system updates:

$ sudo apt update && sudo apt full-upgrade

How to use Bazel