From 3c2dd30dedca86bcf29a3d4c5b29e1c0dfb09d4e Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Sun, 16 Jan 2022 16:41:24 +0800 Subject: [PATCH] Don't end script after downloading image --- docker/start_broker.sh | 11 +++++++---- docker/start_kafka_tool.sh | 11 +++++++---- docker/start_spark.sh | 11 +++++++---- docker/start_zookeeper.sh | 11 +++++++---- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/docker/start_broker.sh b/docker/start_broker.sh index be01e8bfbe..947c83c75e 100755 --- a/docker/start_broker.sh +++ b/docker/start_broker.sh @@ -149,17 +149,20 @@ function generateDockerfile() { function buildImageIfNeed() { if [[ "$(docker images -q $IMAGE_NAME 2>/dev/null)" == "" ]]; then + local needToBuild="true" if [[ "$BUILD" == "false" ]]; then docker pull $IMAGE_NAME 2>/dev/null if [[ "$?" == "0" ]]; then - exit 0 + needToBuild="false" else echo "Can't find $IMAGE_NAME from repo. Will build $IMAGE_NAME on the local" fi fi - docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" - if [[ "$?" != "0" ]]; then - exit 2 + if [[ "$needToBuild" == "true" ]]; then + docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" + if [[ "$?" != "0" ]]; then + exit 2 + fi fi fi } diff --git a/docker/start_kafka_tool.sh b/docker/start_kafka_tool.sh index b1c5ba5af8..fb5aa10ed9 100755 --- a/docker/start_kafka_tool.sh +++ b/docker/start_kafka_tool.sh @@ -51,17 +51,20 @@ RUN cp \$(find ./app/build/libs/ -maxdepth 1 -type f -name app-*-all.jar) /tmp/a function buildImageIfNeed() { if [[ "$(docker images -q $IMAGE_NAME 2>/dev/null)" == "" ]]; then + local needToBuild="true" if [[ "$BUILD" == "false" ]]; then docker pull $IMAGE_NAME 2>/dev/null if [[ "$?" == "0" ]]; then - exit 0 + needToBuild="false" else echo "Can't find $IMAGE_NAME from repo. Will build $IMAGE_NAME on the local" fi fi - docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" - if [[ "$?" != "0" ]]; then - exit 2 + if [[ "$needToBuild" == "true" ]]; then + docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" + if [[ "$?" != "0" ]]; then + exit 2 + fi fi fi } diff --git a/docker/start_spark.sh b/docker/start_spark.sh index 0902c69d74..494c9833e8 100755 --- a/docker/start_spark.sh +++ b/docker/start_spark.sh @@ -147,17 +147,20 @@ function generateDockerfile() { function buildImageIfNeed() { if [[ "$(docker images -q $IMAGE_NAME 2>/dev/null)" == "" ]]; then + local needToBuild="true" if [[ "$BUILD" == "false" ]]; then docker pull $IMAGE_NAME 2>/dev/null if [[ "$?" == "0" ]]; then - exit 0 + needToBuild="false" else echo "Can't find $IMAGE_NAME from repo. Will build $IMAGE_NAME on the local" fi fi - docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" - if [[ "$?" != "0" ]]; then - exit 2 + if [[ "$needToBuild" == "true" ]]; then + docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" + if [[ "$?" != "0" ]]; then + exit 2 + fi fi fi } diff --git a/docker/start_zookeeper.sh b/docker/start_zookeeper.sh index d47f7aad82..0f5bb7d8b9 100755 --- a/docker/start_zookeeper.sh +++ b/docker/start_zookeeper.sh @@ -70,17 +70,20 @@ RUN echo "clientPort=2181" >> ./conf/zoo.cfg function buildImageIfNeed() { if [[ "$(docker images -q $IMAGE_NAME 2>/dev/null)" == "" ]]; then + local needToBuild="true" if [[ "$BUILD" == "false" ]]; then docker pull $IMAGE_NAME 2>/dev/null if [[ "$?" == "0" ]]; then - exit 0 + needToBuild="false" else echo "Can't find $IMAGE_NAME from repo. Will build $IMAGE_NAME on the local" fi fi - docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" - if [[ "$?" != "0" ]]; then - exit 2 + if [[ "$needToBuild" == "true" ]]; then + docker build --no-cache -t "$IMAGE_NAME" -f "$DOCKERFILE" "$DOCKER_FOLDER" + if [[ "$?" != "0" ]]; then + exit 2 + fi fi fi }