mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 22:07:17 +00:00
72 lines
1.9 KiB
Bash
Executable File
72 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eu
|
|
set -o pipefail
|
|
set -o errtrace
|
|
shopt -s expand_aliases
|
|
[ "$(uname)" == "Darwin" ] && alias readlink="greadlink" && alias grep="ggrep" || :
|
|
|
|
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
TFW_PATH="${TFW_PATH:-$SCRIPT_DIR/../..}"
|
|
|
|
BASEIMAGE_REPO="${BASEIMAGE_REPO:-baseimage-tutorial-framework}"
|
|
CHALLENGE_REPO="${CHALLENGE_REPO:-"$(basename "$(realpath "${SCRIPT_DIR}/..")")"}"
|
|
FRONTEND_REPO="${FRONTEND_REPO:-frontend-tutorial-framework}"
|
|
|
|
BASEIMAGE_PATH="${TFW_PATH}/${BASEIMAGE_REPO}"
|
|
CHALLENGE_PATH="${TFW_PATH}/${CHALLENGE_REPO}"
|
|
FRONTEND_PATH="${TFW_PATH}/${FRONTEND_REPO}"
|
|
|
|
source "${SCRIPT_DIR}/libhack/baseimage.sh"
|
|
source "${SCRIPT_DIR}/libhack/challenge.sh"
|
|
source "${SCRIPT_DIR}/libhack/frontend.sh"
|
|
|
|
|
|
try_build_baseimage() {
|
|
if baseimage::check_exists; then
|
|
build_baseimage
|
|
fi
|
|
}
|
|
|
|
build_baseimage() {
|
|
frontend_version="$(frontend::latest_tag)"
|
|
baseimage::build
|
|
}
|
|
|
|
case ${1:-} in
|
|
start)
|
|
try_build_baseimage
|
|
challenge::build
|
|
challenge::run ${@:2}
|
|
;;
|
|
run)
|
|
challenge:run ${@:2}
|
|
;;
|
|
build-baseimage)
|
|
build_baseimage
|
|
;;
|
|
build)
|
|
try_build_baseimage
|
|
challenge::build_no_cache
|
|
;;
|
|
build-frontend)
|
|
frontend::build
|
|
;;
|
|
release-baseimage)
|
|
build_baseimage
|
|
baseimage::release
|
|
;;
|
|
release-frontend)
|
|
frontend::build
|
|
frontend::release
|
|
;;
|
|
*)
|
|
echo "Usage: tfw.sh [COMMAND]"
|
|
echo " |--- start: build & run TFW challenge"
|
|
echo " |--- run: run TFW challenge"
|
|
echo " |--- build-baseimage: build TFW baseimage"
|
|
echo " |--- build: build TFW baseimage and challenge"
|
|
echo " |--- release-baseimage: tag TFW baseimage and push to DockerHub"
|
|
echo " |--- release-frontend: tag TFW frontend and push to DockerHub"
|
|
;;
|
|
esac
|