mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 02:57:18 +00:00
Refactor tfw.sh to make usage more intuitive
This commit is contained in:
parent
459f0e9411
commit
be3146533f
44
hack/tfw.sh
44
hack/tfw.sh
@ -18,10 +18,11 @@ TEST_PORT="${TEST_PORT:-8888}"
|
|||||||
AVATAO_SECRET="${AVATAO_SECRET:-secret}"
|
AVATAO_SECRET="${AVATAO_SECRET:-secret}"
|
||||||
BUILD_CONTEXT="${BUILD_CONTEXT:-solvable}"
|
BUILD_CONTEXT="${BUILD_CONTEXT:-solvable}"
|
||||||
|
|
||||||
run_frontend()
|
build_baseimage()
|
||||||
{
|
{
|
||||||
cd $FRONTEND_PATH
|
[ ! -d "$BASEIMAGE_PATH" ] && return || :
|
||||||
yarn start
|
cd $BASEIMAGE_PATH
|
||||||
|
docker build -t "${BASEIMAGE_NAME}:$(baseimage_releasename)" -t "${BASEIMAGE_NAME}:latest" .
|
||||||
}
|
}
|
||||||
|
|
||||||
release_baseimage()
|
release_baseimage()
|
||||||
@ -37,13 +38,6 @@ release_baseimage()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
build_baseimage()
|
|
||||||
{
|
|
||||||
[ ! -d "$BASEIMAGE_PATH" ] && return || :
|
|
||||||
cd $BASEIMAGE_PATH
|
|
||||||
docker build -t "${BASEIMAGE_NAME}:$(baseimage_releasename)" -t "${BASEIMAGE_NAME}:latest" .
|
|
||||||
}
|
|
||||||
|
|
||||||
baseimage_releasename()
|
baseimage_releasename()
|
||||||
{
|
{
|
||||||
VERSION="$(cat VERSION | head -n 1)"
|
VERSION="$(cat VERSION | head -n 1)"
|
||||||
@ -53,6 +47,7 @@ baseimage_releasename()
|
|||||||
|
|
||||||
build_test()
|
build_test()
|
||||||
{
|
{
|
||||||
|
build_baseimage
|
||||||
cd $TEST_PATH
|
cd $TEST_PATH
|
||||||
docker build -t $IMAGE_NAME -f ${BUILD_CONTEXT}/Dockerfile --build-arg BUILD_CONTEXT=$BUILD_CONTEXT --build-arg NOFRONTEND=1 .
|
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
|
run_test
|
||||||
}
|
}
|
||||||
|
|
||||||
build_and_start_tfw()
|
run_frontend()
|
||||||
{
|
{
|
||||||
trap 'exit' INT TERM
|
cd $FRONTEND_PATH
|
||||||
trap 'kill 0' EXIT
|
yarn start
|
||||||
build_baseimage
|
|
||||||
run_frontend & build_and_run_test
|
|
||||||
wait
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_tfw()
|
start_test()
|
||||||
{
|
{
|
||||||
trap 'exit' INT TERM
|
trap 'exit' INT TERM
|
||||||
trap 'kill 0' EXIT
|
trap 'kill 0' EXIT
|
||||||
run_frontend & run_test
|
run_frontend & build_and_run_test
|
||||||
wait
|
wait
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,24 +81,20 @@ case $1 in
|
|||||||
buildtfw)
|
buildtfw)
|
||||||
build_baseimage
|
build_baseimage
|
||||||
;;
|
;;
|
||||||
|
releasetfw)
|
||||||
|
release_baseimage
|
||||||
|
;;
|
||||||
build)
|
build)
|
||||||
build_test
|
build_test
|
||||||
;;
|
;;
|
||||||
start)
|
start)
|
||||||
start_tfw
|
start_test
|
||||||
;;
|
;;
|
||||||
buildstart)
|
|
||||||
build_and_start_tfw
|
|
||||||
;;
|
|
||||||
release)
|
|
||||||
release_baseimage
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: tfw.sh [buildtfw|build|start|buildstart]"
|
echo "Usage: tfw.sh [buildtfw|build|start|buildstart]"
|
||||||
echo " |--- buildtfw: build TFW baseimage"
|
echo " |--- buildtfw: build TFW baseimage"
|
||||||
|
echo " |--- releasetfw: tag TFW baseimage and push to upstream"
|
||||||
echo " |--- build: build TFW test"
|
echo " |--- build: build TFW test"
|
||||||
echo " |--- start: start TFW test"
|
echo " |--- start: build & start TFW test"
|
||||||
echo " |--- buildstart: build all, then start TFW test"
|
|
||||||
echo " |--- release: tag TFW baseimage and push to upstream"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user