summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-05-07 16:37:53 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-07 16:39:37 -0700
commit5536073969ae1805fc77743e7aac540af6b66a3e (patch)
tree3ba94096b09b496477e0e75df3174cdd18ed3b26
parent7b4a913f36e2fededca9b1d2f73588eca9c4b683 (diff)
make: bazel docker container should clean itself up.
This change two does things: 1) Name the container based on the canonical directory path. 2) Allow the container to exit after bazel itself has exited. The first is necessary to support multiple working directories, while the second one allows these instances to clean up properly. PiperOrigin-RevId: 310460748
-rw-r--r--tools/bazel.mk5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/bazel.mk b/tools/bazel.mk
index 45fbbecca..71641970d 100644
--- a/tools/bazel.mk
+++ b/tools/bazel.mk
@@ -21,7 +21,7 @@ BRANCH_NAME := $(shell (git branch --show-current 2>/dev/null || \
# Bazel container configuration (see below).
USER ?= gvisor
-DOCKER_NAME ?= gvisor-bazel
+DOCKER_NAME ?= gvisor-bazel-$(shell readlink -m $(CURDIR) | md5sum | cut -c1-8)
DOCKER_RUN_OPTIONS ?= --privileged
BAZEL_CACHE := $(shell readlink -m ~/.cache/bazel/)
GCLOUD_CONFIG := $(shell readlink -m ~/.config/gcloud/)
@@ -50,6 +50,7 @@ FULL_DOCKER_RUN_OPTIONS += -v "$(DOCKER_SOCKET):$(DOCKER_SOCKET)"
##
bazel-server-start: load-default ## Starts the bazel server.
docker run -d --rm \
+ --init \
--name $(DOCKER_NAME) \
--user 0:0 \
-v "$(CURDIR):$(CURDIR)" \
@@ -61,7 +62,7 @@ bazel-server-start: load-default ## Starts the bazel server.
sh -c "groupadd --gid $(GID) --non-unique $(USER) && \
useradd --uid $(UID) --non-unique --no-create-home --gid $(GID) -d $(HOME) $(USER) && \
bazel version && \
- while :; do sleep 3600; done"
+ exec tail --pid=\$$(bazel info server_pid) -f /dev/null"
@while :; do if docker logs $(DOCKER_NAME) 2>/dev/null | grep "Build label:" >/dev/null; then break; fi; sleep 1; done
.PHONY: bazel-server-start