From 82084c9717be5028b52c56fcaae3bdc07d18a23a Mon Sep 17 00:00:00 2001 From: Alex Kaminskii Date: Wed, 4 May 2022 11:23:38 +0200 Subject: [PATCH] fix (backend): build.sh build_service incapsulate --- backend/build.sh | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/backend/build.sh b/backend/build.sh index 5a52b1063..4b55b787e 100755 --- a/backend/build.sh +++ b/backend/build.sh @@ -18,6 +18,27 @@ check_prereq() { return } + +function build_service() { + image="$1" + echo "BUILDING $image" + case "$image" in + http) + echo build http + docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image -f ./cmd/Dockerfile . + [[ $PUSH_IMAGE -eq 1 ]] && { + docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1} + } + ;; + *) + docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image . + [[ $PUSH_IMAGE -eq 1 ]] && { + docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1} + } + ;; + esac +} + function build_api(){ # Copy enterprise code [[ $1 == "ee" ]] && { @@ -25,31 +46,12 @@ function build_api(){ ee="true" } [[ $2 != "" ]] && { - image="$2" - docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image . - [[ $PUSH_IMAGE -eq 1 ]] && { - docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1} - } - echo "build completed for http" + build_service $2 return } for image in $(ls services); do - case "$image" in - http) - echo build http - docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image -f ./cmd/Dockerfile . - [[ $PUSH_IMAGE -eq 1 ]] && { - docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1} - } - ;; - *) - docker build -t ${DOCKER_REPO:-'local'}/$image:${git_sha1} --build-arg SERVICE_NAME=$image . - [[ $PUSH_IMAGE -eq 1 ]] && { - docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1} - } - ;; - esac + build_service $image echo "::set-output name=image::${DOCKER_REPO:-'local'}/$image:${git_sha1}" done echo "backend build completed"