*: bring our own sandbox root

This change removes the build container and replaces it with a
Bazel-built Fedora 37 sysroot which is bind-mounted into the Bazel
sandbox using --sandbox_add_mount_pair. The tools/bazel wrapper script
automatically (re-)generates the sysroot when needed.

Both Bazelisk and Bazel's native wrapper automatically run the
tools/bazel script, which means that our build should now work without
extra steps on any machine with a working Bazelisk setup and unpriv ns.

This fixes all kinds of weirdness caused by the previous podman setup
("bazel run"/container pushes, log access, weird podman bugs,
breaking the IDE plugin for any non-Monogon workspaces...).

Using the sandbox hash as an action var also ensures that the cache
is invalidated whenever the ambient environment changes. Previously,
Bazel did not invalidate build steps when any host dependency changed.
To my knowledge, this was the only remaining cause for stale builds.

It also means we cannot depend on the host toolchain since it
won't be accessible in the sandbox, and anything that inspects the
host during analysis stage will fail. This currently means that
running on a non-Fedora host won't work - we fix this next.

All RPMs are pinned and the sysroot is fully reproducible.

Once we upgrade to Bazel 5.x, we can take it further by enabling
--experimental_use_hermetic_linux_sandbox and fully remove the
remaining host paths from the sandbox for full hermeticity.

In a follow-up, we can clean up the CI image to only contain the
minimum dependencies needed for Bazelisk and the agent.

Existing IntelliJ users need to remove the -Dbazel.bep.path flag
from their VM options.

Handbook/Rust rules are disabled temporarily to keep CI green
(requires a more recent rules_rust version).

Change-Id: I1f17d57d985ff9d749bf3359f259d8ef52247c18
Reviewed-on: https://review.monogon.dev/c/monogon/+/1033
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
27 files changed
tree: 02ead12ee79b10abfdd624071802acc771f6bb3e
  1. .github/
  2. build/
  3. cloud/
  4. intellij/
  5. metropolis/
  6. third_party/
  7. tools/
  8. .bazelignore
  9. .bazelproject
  10. .bazelrc
  11. .bazelrc.sandboxroot
  12. .bazelversion
  13. .git-ignore-revs
  14. .gitignore
  15. BUILD
  16. CODING_STANDARDS.md
  17. go.mod
  18. go.sum
  19. LICENSE
  20. README.md
  21. WORKSPACE
README.md

Monogon Monorepo

This is the main repository containing the source code for the Monogon Platform.

This is pre-release software - take a look, and check back later!

Environment

Our build environment is self-contained and requires only minimal host dependencies:

  • A Linux machine or VM.
  • Bazelisk >= v1.15.0
  • A reasonably recent kernel with user namespaces enabled.
  • Working KVM with access to /dev/kvm (if you want to run tests).

Our docs assume that Bazelisk is available as bazel on your PATH.

IntelliJ support

This repository is compatible with the IntelliJ Bazel plugin out of the box, which enables full autocompletion for external dependencies and generated code.

The following steps are necessary:

  • Install Google's Bazel plugin in IntelliJ.

  • Make sure that Bazel "Bazel Binary Location" in Other Settings → Bazel Settings points to Bazelisk.

  • Use File → Import Bazel project... and select your monorepo checkout.

After running the first sync, everything should now resolve in the IDE, including generated code.

Monogon OS

Run a single node demo cluster

Launch the node:

bazel run //:launch -c dbg

Run a kubectl command:

bazel run //metropolis/cli/dbg -c dbg -- kubectl describe node

Test suite

Run full test suite:

bazel test -c dbg //...