2018-03-23 16:58:24 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-03-23 20:39:39 +00:00
|
|
|
set -eo pipefail
|
2018-03-23 16:58:24 +00:00
|
|
|
|
|
|
|
[ "$(uname)" == "Darwin" ] && readlink_cmd="greadlink" || readlink_cmd="readlink"
|
|
|
|
SCRIPT_DIR="$(dirname $($readlink_cmd -f $0))"
|
|
|
|
|
|
|
|
TAO_PATH="${TAO_PATH:-$SCRIPT_DIR/../..}"
|
2018-03-25 14:03:13 +00:00
|
|
|
BASEIMAGE_REPO="${BASEIMAGE_REPO:-baseimage-tutorial-framework}"
|
2018-03-23 16:58:24 +00:00
|
|
|
BACKEND_REPO="${BACKEND_REPO:-test-tutorial-framework}"
|
|
|
|
FRONTEND_REPO="${FRONTEND_REPO:-frontend-tutorial-framework}"
|
2018-03-25 14:03:13 +00:00
|
|
|
BASEIMAGE_PATH="${TAO_PATH}/${BASEIMAGE_REPO}"
|
2018-03-23 16:58:24 +00:00
|
|
|
BACKEND_PATH="${TAO_PATH}/${BACKEND_REPO}"
|
|
|
|
FRONTEND_PATH="${TAO_PATH}/${FRONTEND_REPO}"
|
|
|
|
|
2018-03-25 14:03:13 +00:00
|
|
|
BASEIMAGE_NAME="${BASEIMAGE_NAME:-baseimage-tutorial-framework}"
|
|
|
|
IMAGE_NAME="${IMAGE_NAME:-test-tutorial-framework}"
|
2018-03-23 16:58:24 +00:00
|
|
|
BACKEND_PORT="${BACKEND_PORT:-8888}"
|
|
|
|
AVATAO_SECRET="${AVATAO_SECRET:-secret}"
|
|
|
|
BUILD_CONTEXT="${BUILD_CONTEXT:-solvable}"
|
|
|
|
|
2018-03-25 14:06:16 +00:00
|
|
|
run_frontend()
|
2018-03-23 16:58:24 +00:00
|
|
|
{
|
|
|
|
cd $FRONTEND_PATH
|
|
|
|
yarn start
|
|
|
|
}
|
|
|
|
|
2018-03-25 14:06:16 +00:00
|
|
|
build_baseimage()
|
2018-03-25 14:03:13 +00:00
|
|
|
{
|
|
|
|
cd $BASEIMAGE_PATH
|
2018-03-27 11:37:59 +00:00
|
|
|
VERSION="$(cat VERSION | head -n 1)"
|
|
|
|
DATE="$(date +%Y%m%d)"
|
|
|
|
docker build -t "${BASEIMAGE_NAME}:${VERSION}-${DATE}" .
|
2018-03-25 14:03:13 +00:00
|
|
|
}
|
|
|
|
|
2018-03-25 14:06:16 +00:00
|
|
|
run_backend()
|
2018-03-23 16:58:24 +00:00
|
|
|
{
|
|
|
|
cd $BACKEND_PATH
|
|
|
|
docker build -t $IMAGE_NAME -f ${BUILD_CONTEXT}/Dockerfile --build-arg BUILD_CONTEXT=$BUILD_CONTEXT --build-arg NOFRONTEND=1 .
|
|
|
|
docker run --rm -p $BACKEND_PORT:$BACKEND_PORT -e AVATAO_SECRET=$AVATAO_SECRET $IMAGE_NAME
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'exit' INT TERM
|
|
|
|
trap 'kill 0' EXIT
|
2018-03-25 14:03:13 +00:00
|
|
|
build_baseimage
|
2018-03-23 16:58:24 +00:00
|
|
|
run_frontend & run_backend
|
|
|
|
wait
|