From be3146533f9aed8ba5175f9bab076b5b68dd5f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 31 Mar 2018 19:01:59 +0200 Subject: [PATCH] Refactor tfw.sh to make usage more intuitive --- hack/tfw.sh | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/hack/tfw.sh b/hack/tfw.sh index f6a37d1..ed674aa 100755 --- a/hack/tfw.sh +++ b/hack/tfw.sh @@ -18,10 +18,11 @@ TEST_PORT="${TEST_PORT:-8888}" AVATAO_SECRET="${AVATAO_SECRET:-secret}" BUILD_CONTEXT="${BUILD_CONTEXT:-solvable}" -run_frontend() +build_baseimage() { - cd $FRONTEND_PATH - yarn start + [ ! -d "$BASEIMAGE_PATH" ] && return || : + cd $BASEIMAGE_PATH + docker build -t "${BASEIMAGE_NAME}:$(baseimage_releasename)" -t "${BASEIMAGE_NAME}:latest" . } release_baseimage() @@ -37,13 +38,6 @@ release_baseimage() fi } -build_baseimage() -{ - [ ! -d "$BASEIMAGE_PATH" ] && return || : - cd $BASEIMAGE_PATH - docker build -t "${BASEIMAGE_NAME}:$(baseimage_releasename)" -t "${BASEIMAGE_NAME}:latest" . -} - baseimage_releasename() { VERSION="$(cat VERSION | head -n 1)" @@ -53,6 +47,7 @@ baseimage_releasename() build_test() { + build_baseimage cd $TEST_PATH docker build -t $IMAGE_NAME -f ${BUILD_CONTEXT}/Dockerfile --build-arg BUILD_CONTEXT=$BUILD_CONTEXT --build-arg NOFRONTEND=1 . } @@ -68,20 +63,17 @@ build_and_run_test() run_test } -build_and_start_tfw() +run_frontend() { - trap 'exit' INT TERM - trap 'kill 0' EXIT - build_baseimage - run_frontend & build_and_run_test - wait + cd $FRONTEND_PATH + yarn start } -start_tfw() +start_test() { trap 'exit' INT TERM trap 'kill 0' EXIT - run_frontend & run_test + run_frontend & build_and_run_test wait } @@ -89,24 +81,20 @@ case $1 in buildtfw) build_baseimage ;; + releasetfw) + release_baseimage + ;; build) build_test ;; start) - start_tfw + start_test ;; - buildstart) - build_and_start_tfw - ;; - release) - release_baseimage - ;; *) echo "Usage: tfw.sh [buildtfw|build|start|buildstart]" echo " |--- buildtfw: build TFW baseimage" + echo " |--- releasetfw: tag TFW baseimage and push to upstream" echo " |--- build: build TFW test" - echo " |--- start: start TFW test" - echo " |--- buildstart: build all, then start TFW test" - echo " |--- release: tag TFW baseimage and push to upstream" + echo " |--- start: build & start TFW test" ;; esac