From 0bd333b5ec0541ad71375a10ab49243cec4ecee0 Mon Sep 17 00:00:00 2001 From: Roman Mohr Date: Thu, 7 Mar 2019 18:13:57 +0100 Subject: [PATCH] Run bazel build server always in the background Speed up all bazel related operations because it does not have to run in batch mode. --- cluster/ephemeral-provider-common.sh | 2 +- hack/bazel-server.sh | 2 ++ hack/dockerized | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100755 hack/bazel-server.sh diff --git a/cluster/ephemeral-provider-common.sh b/cluster/ephemeral-provider-common.sh index 6045c9690d50..96d5666f4552 100644 --- a/cluster/ephemeral-provider-common.sh +++ b/cluster/ephemeral-provider-common.sh @@ -41,7 +41,7 @@ function _add_common_params() { function build() { # Build everyting and publish it ${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} ./hack/build-manifests.sh" - DOCKER_PREFIX=${docker_prefix} DOCKER_TAG=${docker_tag} make bazel-push-images + hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-push-images.sh" # Make sure that all nodes use the newest images container="" diff --git a/hack/bazel-server.sh b/hack/bazel-server.sh new file mode 100755 index 000000000000..f8ce68dd45fb --- /dev/null +++ b/hack/bazel-server.sh @@ -0,0 +1,2 @@ +BAZEL_PID=$(bazel info | grep server_pid | cut -d " " -f 2) +while kill -0 $BAZEL_PID 2>/dev/null; do sleep 1; done diff --git a/hack/dockerized b/hack/dockerized index 772974771f57..5c8399fa2b10 100755 --- a/hack/dockerized +++ b/hack/dockerized @@ -101,9 +101,15 @@ if [ -d "${HOME}/.docker" ]; then volumes="$volumes -v ${HOME}/.docker:/root/.docker:ro,z" fi +# Ensure that a bazel server is running + +if [ -z "$(docker ps --format '{{.Names}}' | grep ${BUILDER}-bazel-server)" ]; then + docker run --network host -d ${volumes} --security-opt label:disable --name ${BUILDER}-bazel-server -w "/root/go/src/kubevirt.io/kubevirt" --rm ${BUILDER} hack/bazel-server.sh +fi + # Run the command test -t 1 && USE_TTY="-it" -docker run --network host --rm ${volumes} --security-opt label:disable ${USE_TTY} -w "/root/go/src/kubevirt.io/kubevirt" ${BUILDER} "$@" +docker exec ${USE_TTY} ${BUILDER}-bazel-server /entrypoint.sh "$@" # Copy the whole kubevirt data out to get generated sources and formatting changes _rsync \