Separate cache volume for each working copy
We can rely on the repository leases to coordinate Bazel caches,
basically leasing them out along with the repository.
With multiple copies of the cache, keeping them on a tmpfs seems
like a bad idea, so we switch to a local volume.
Test Plan: Covered by CI
X-Origin-Diff: phab/D250
GitOrigin-RevId: 01d9392198d8c00089d3133425091ab766b9b590
diff --git a/scripts/run_ci.sh b/scripts/run_ci.sh
index d25531d..c310c55 100755
--- a/scripts/run_ci.sh
+++ b/scripts/run_ci.sh
@@ -9,6 +9,16 @@
TAG=nexantic-build-${BUILD_ID}
POD=nexantic-build-${BUILD_ID}
+# We keep one Bazel build cache per working copy to avoid concurrency issues
+# (we cannot run multiple Bazel servers on a given _bazel_root)
+function getWorkingCopyID {
+ local pattern='/var/drydock/workingcopy-([0-9]+)/'
+ [[ "$(pwd)" =~ $pattern ]]
+ echo ${BASH_REMATCH[1]}
+}
+
+CACHE_VOLUME=bazel-cache-$(getWorkingCopyID)
+
# New image for each build - the Dockerfile might have changed.
# Rely on the build step cache to avoid costly rebuilds.
podman build -t ${TAG} build
@@ -24,11 +34,7 @@
trap cleanup EXIT
-! podman volume create \
- --opt device=tmpfs \
- --opt type=tmpfs \
- --opt o=nodev,exec \
- bazel-shared-cache
+! podman volume create --opt o=nodev,exec ${CACHE_VOLUME}
podman pod create --name ${POD}