Mount Bazel repository_cache, Go mod cache and Go build cache as volumes
This leaves us with only git_repository rules not being cached,
the worst offender being the edk2 recursive submodule clone.
See: https://github.com/bazelbuild/bazel/issues/5116
gazelle's repo lookup (running `go list`) is also not cached, even if the
repositories themselves are.
We can eliminate most of the remaining rebuild time by mounting
the entire execroot, however, this is currently foiled by a podman bug
(Bazel needs to execute lots of binaries inside the root):
https://github.com/containers/libpod/issues/4318
Test Plan:
Ran `bazel build scripts:launch`, recreated container, ran it again.
Build times decreased significantly:
INFO: Elapsed time: 279.951s, Critical Path: 119.05s
INFO: 477 processes: 476 linux-sandbox, 1 local.
INFO: Build completed successfully, 497 total actions
X-Origin-Diff: phab/D206
GitOrigin-RevId: 2d17a7eeb5d8b70ad4e26c13a0c6b31c4edfb33f
diff --git a/scripts/create_container.sh b/scripts/create_container.sh
index 84a5740..359d2ee 100755
--- a/scripts/create_container.sh
+++ b/scripts/create_container.sh
@@ -24,8 +24,13 @@
chcon -R unconfined_u:object_r:user_home_t:s0 \
.arcconfig .idea .git
+# TODO(leo): mount .cache/bazel on a volume (waiting for podman issue to be fixed)
+# https://github.com/containers/libpod/issues/4318
podman run -it -d \
-v $(pwd):/work \
+ -v smalltown-gomodcache:/root/go/pkg/mod/cache \
+ -v smalltown-gobuildcache:/root/.cache/go-build \
+ -v smalltown-bazelcache:/root/.cache/bazel/_bazel_root/cache \
--tmpfs=/root/.cache/bazel:exec \
--device /dev/kvm \
--privileged \