2018-03-23 20:40:24 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-03-23 20:39:39 +00:00
|
|
|
set -eo pipefail
|
2018-04-03 16:03:12 +00:00
|
|
|
shopt -s expand_aliases
|
2018-03-23 16:58:24 +00:00
|
|
|
|
2018-03-24 10:47:38 +00:00
|
|
|
TFW_POSTFIX=tutorial-framework
|
|
|
|
BASEIMAGE=baseimage-${TFW_POSTFIX}
|
2018-03-30 21:56:14 +00:00
|
|
|
TEST=test-${TFW_POSTFIX}
|
2018-03-24 10:47:38 +00:00
|
|
|
FRONTEND=frontend-${TFW_POSTFIX}
|
|
|
|
LOGFILE=/tmp/bootstrap_tfw.log
|
2018-03-24 11:18:59 +00:00
|
|
|
|
2018-04-03 16:03:12 +00:00
|
|
|
[ "$(uname)" == "Darwin" ] && alias sed="gsed" || :
|
2018-03-30 23:26:17 +00:00
|
|
|
|
2018-03-24 11:18:59 +00:00
|
|
|
showlog() { echo && echo "Error! Showing logs:" && cat $LOGFILE; }
|
|
|
|
cleanlog() { rm $LOGFILE; }
|
|
|
|
trap showlog ERR
|
|
|
|
trap cleanlog EXIT
|
2018-03-23 16:58:24 +00:00
|
|
|
|
2018-03-24 10:48:54 +00:00
|
|
|
: > $LOGFILE
|
2018-03-23 22:09:39 +00:00
|
|
|
echo -n "Cloning TFW repositories... "
|
2018-03-30 23:26:17 +00:00
|
|
|
[ ! -z "$TFWDEV" ] && echo -n "baseimage... " && git clone git@github.com:avatao-content/${BASEIMAGE}.git >> $LOGFILE 2>&1 || :
|
2018-03-24 10:47:38 +00:00
|
|
|
echo -n "frontend... " && git clone git@github.com:avatao-content/${FRONTEND}.git >> $LOGFILE 2>&1
|
2018-03-30 21:56:14 +00:00
|
|
|
echo -n "test... " && git clone git@github.com:avatao-content/${TEST}.git >> $LOGFILE 2>&1
|
2018-03-23 22:09:39 +00:00
|
|
|
echo "Done!"
|
2018-03-23 16:58:24 +00:00
|
|
|
|
2018-03-31 17:19:16 +00:00
|
|
|
echo -n "Installing frontend dependencies... "
|
|
|
|
cd ${FRONTEND}
|
|
|
|
yarn install >> $LOGFILE 2>&1
|
|
|
|
cd ..
|
|
|
|
echo "Done!"
|
|
|
|
|
2018-03-30 23:26:17 +00:00
|
|
|
if [ -z "$TFWDEV" ]; then
|
2018-03-31 19:22:33 +00:00
|
|
|
echo -n "Pinning latest TFW baseimage version... "
|
2018-03-30 23:26:17 +00:00
|
|
|
TFWURL=https://registry.hub.docker.com/v1/repositories/avatao/tutorial-framework/tags
|
|
|
|
PYTHON_PARSEJSON="import sys, json; print json.load(sys.stdin)[-1]['name']"
|
|
|
|
LATESTTAG="$(curl -fsSL ${TFWURL} | python -c "${PYTHON_PARSEJSON}")"
|
2018-04-03 16:03:12 +00:00
|
|
|
sed -i "1 s/.*/&:${LATESTTAG}/" "${TEST}/solvable/Dockerfile"
|
2018-03-31 19:22:33 +00:00
|
|
|
echo "Done!"
|
2018-03-31 17:19:16 +00:00
|
|
|
|
2018-03-30 23:26:17 +00:00
|
|
|
rm -rf "${TEST}/.git"
|
|
|
|
rm -rf "${FRONTEND}/.git"
|
|
|
|
|
2018-03-31 19:22:33 +00:00
|
|
|
echo -n "Merging repositories... "
|
2018-03-31 17:19:16 +00:00
|
|
|
NESTED_FRONTEND="${TEST}/solvable/frontend"
|
|
|
|
rm -rf $NESTED_FRONTEND
|
|
|
|
mv "$FRONTEND" "$NESTED_FRONTEND"
|
2018-03-31 19:22:33 +00:00
|
|
|
echo "Done!"
|
2018-03-31 17:19:16 +00:00
|
|
|
fi
|
2018-03-23 16:58:24 +00:00
|
|
|
|
2018-03-24 11:01:37 +00:00
|
|
|
echo
|
2018-03-31 18:02:01 +00:00
|
|
|
echo "You can build & start TFW by executing the command: ${TEST}/hack/tfw.sh start"
|