The new docker image doesn't have enough packages to rebuild binary modules. This should be handled by the docker build scripts, and thus we can't just upgrade the virtualenv from within the docker image.
93 lines
3.2 KiB
Bash
Executable File
93 lines
3.2 KiB
Bash
Executable File
#!/bin/bash -e
|
|
|
|
# Deploys the current production branch to the production machine.
|
|
PROJECT_NAME="blender-cloud"
|
|
DOCKER_NAME="blender_cloud"
|
|
REMOTE_ROOT="/data/git/${PROJECT_NAME}"
|
|
|
|
SSH="ssh -o ClearAllForwardings=yes cloud.blender.org"
|
|
ROOT="$(dirname "$(readlink -f "$0")")"
|
|
cd ${ROOT}
|
|
|
|
# Check that we're on production branch.
|
|
if [ $(git rev-parse --abbrev-ref HEAD) != "production" ]; then
|
|
echo "You are NOT on the production branch, refusing to deploy." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Check that production branch has been pushed.
|
|
if [ -n "$(git log origin/production..production --oneline)" ]; then
|
|
echo "WARNING: not all changes to the production branch have been pushed."
|
|
echo "Press [ENTER] to continue deploying current origin/production, CTRL+C to abort."
|
|
read dummy
|
|
fi
|
|
|
|
# Find Pillar
|
|
PILLAR_DIR=$(python <<EOT
|
|
from __future__ import print_function
|
|
import os.path
|
|
try:
|
|
import pillar
|
|
except ImportError:
|
|
raise SystemExit('Pillar not found on Python path. Are you in the correct venv?')
|
|
|
|
print(os.path.dirname(os.path.dirname(pillar.__file__)))
|
|
EOT
|
|
)
|
|
if [ $(git -C $PILLAR_DIR rev-parse --abbrev-ref HEAD) != "production" ]; then
|
|
echo "Pillar ($PILLAR_DIR) NOT on the production branch, refusing to deploy." >&2
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# SSH to cloud to pull all files in
|
|
function git_pull() {
|
|
PROJECT_NAME="$1"
|
|
BRANCH="$2"
|
|
REMOTE_ROOT="/data/git/${PROJECT_NAME}"
|
|
|
|
echo "==================================================================="
|
|
echo "UPDATING FILES ON ${PROJECT_NAME}"
|
|
${SSH} git -C ${REMOTE_ROOT} fetch origin ${BRANCH}
|
|
${SSH} git -C ${REMOTE_ROOT} log origin/${BRANCH}..${BRANCH} --oneline
|
|
${SSH} git -C ${REMOTE_ROOT} merge --ff-only origin/${BRANCH}
|
|
}
|
|
|
|
git_pull pillar-python-sdk master
|
|
git_pull pillar production
|
|
git_pull blender-cloud production
|
|
|
|
# Update the virtualenv
|
|
#${SSH} -t docker exec ${DOCKER_NAME} /data/venv/bin/pip install -U -r ${REMOTE_ROOT}/requirements.txt --exists-action w
|
|
|
|
# RSync the world
|
|
./rsync_ui.sh
|
|
|
|
# Notify Bugsnag of this new deploy.
|
|
echo
|
|
echo "==================================================================="
|
|
GIT_REVISION=$(${SSH} git -C ${REMOTE_ROOT} describe --always)
|
|
echo "Notifying Bugsnag of this new deploy of revision ${GIT_REVISION}."
|
|
BUGSNAG_API_KEY=$(${SSH} python -c "\"import sys; sys.path.append('${REMOTE_ROOT}'); import config_local; print(config_local.BUGSNAG_API_KEY)\"")
|
|
curl --data "apiKey=${BUGSNAG_API_KEY}&revision=${GIT_REVISION}" https://notify.bugsnag.com/deploy
|
|
echo
|
|
|
|
# Wait for [ENTER] to restart the server
|
|
echo
|
|
echo "==================================================================="
|
|
echo "NOTE: If you want to edit config_local.py on the server, do so now."
|
|
echo "NOTE: Press [ENTER] to continue and restart the server process."
|
|
read dummy
|
|
${SSH} docker exec ${DOCKER_NAME} apache2ctl graceful
|
|
echo "Server process restarted"
|
|
|
|
echo
|
|
echo "==================================================================="
|
|
echo "Clearing front page from Redis cache."
|
|
${SSH} docker exec redis redis-cli DEL pwview//
|
|
|
|
echo
|
|
echo "==================================================================="
|
|
echo "Deploy of ${PROJECT_NAME} is done."
|
|
echo "==================================================================="
|