Page MenuHome

prep_docker_img.sh
No OneTemporary

File Metadata

Created
Sun, Oct 20, 6:48 PM

prep_docker_img.sh

#!/bin/bash -e
DEPLOY_BRANCH=${DEPLOY_BRANCH:-production}
DOCKER_TAG="armadillica/blender-mydata"
# macOS does not support readlink -f, so we use greadlink instead
if [[ `uname` == 'Darwin' ]]; then
command -v greadlink 2>/dev/null 2>&1 || { echo >&2 "Install greadlink using brew."; exit 1; }
readlink='greadlink'
else
readlink='readlink'
fi
MY_DIR="$(dirname "$($readlink -f "$0")")"
cd "$MY_DIR"
ROOT="$(dirname "$MY_DIR")"
DEPLOYDIR="$ROOT/docker/deploy"
PROJECT_NAME="mydata"
rm -rf "$DEPLOYDIR"/{mydata,opendata}
mkdir -p $DEPLOYDIR
REMOTE_ROOT="$DEPLOYDIR/$PROJECT_NAME"
# Check that production branch has been pushed.
if [ -n "$(git log origin/$DEPLOY_BRANCH..$DEPLOY_BRANCH --oneline)" ]; then
echo "WARNING: not all changes to the $DEPLOY_BRANCH branch have been pushed."
echo "Press [ENTER] to continue deploying current origin/$DEPLOY_BRANCH, CTRL+C to abort."
read dummy
fi
function git_clone() {
REPO_NAME="$1"
URL="$2"
BRANCH="$DEPLOY_BRANCH"
set -e
echo "==================================================================="
echo "CLONING REPO ON $REPO_NAME @$BRANCH"
git -C "$DEPLOYDIR" clone --depth 1 --branch $BRANCH $URL $REPO_NAME
git -C "$DEPLOYDIR/$REPO_NAME" submodule init
git -C "$DEPLOYDIR/$REPO_NAME" submodule update --recommend-shallow
# We need *some* settings to be able to run `manage.py collectstatic` later.
# That command is given while building the docker image.
cp "$MY_DIR/deploytime-settings-$REPO_NAME.py" $DEPLOYDIR/$REPO_NAME/$REPO_NAME/settings.py
}
git_clone mydata git@git.blender.org:blender-my-data.git
git_clone opendata git@git.blender.org:blender-open-data.git
# Gulp everywhere
# TODO: reinstate this, because it's much faster:
# GULP=$ROOT/node_modules/.bin/gulp
# if [ ! -e $GULP -o gulpfile.js -nt $GULP ]; then
# npm install
# touch $GULP # installer doesn't always touch this after a build, so we do.
# fi
# $GULP --cwd $DEPLOYDIR/mydata --production
# $GULP --cwd $DEPLOYDIR/opendata --production
pushd "$DEPLOYDIR/mydata"
./gulp
rm -rf node_modules
popd
pushd "$DEPLOYDIR/opendata"
./gulp
rm -rf node_modules
popd
echo
echo "==================================================================="
echo "Deploy of ${PROJECT_NAME} is ready for dockerisation."
echo "==================================================================="

Event Timeline