-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkershner-deploy
65 lines (50 loc) · 1.6 KB
/
kershner-deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
####################################
# Place this file in /usr/local/sbin
####################################
BASEDIR=/home/ubuntu/kershner
DJANGODIR=$BASEDIR/kershner
VENVDIR=$BASEDIR/venv
PIP="$VENVDIR/bin/pip"
PYTHON="$VENVDIR/bin/python"
PROD_SETTINGS="--settings=site_config.settings.prod"
# react apps
REACT_BASE_DIR=$BASEDIR/static/react-apps
COLOR_DOODLE_DIR=$REACT_BASE_DIR/colorDoodle
MUSIC_PLAYER_DIR=$REACT_BASE_DIR/musicPlayer
echo '==========[ DEPLOYING KERSHNER.ORG ]=========='
echo ''
echo '==========[ Stopping supervisor ]=========='
sudo service supervisor stop
echo ''
echo '==========[ Reverting repo to HEAD (git checkout .) ]=========='
cd $DJANGODIR
git checkout .
echo ''
echo '==========[ git pull ]=========='
git pull origin master
echo ''
echo '==========[ Installing Python requirements ]=========='
$PIP install -q -r $BASEDIR/requirements.txt --no-cache-dir
echo ''
echo '==========[ Migrating DB ]=========='
$PYTHON $BASEDIR/manage.py makemigrations $PROD_SETTINGS
$PYTHON $BASEDIR/manage.py migrate $PROD_SETTINGS
echo ''
echo '==========[ Compiling front end assets (react etc) ]=========='
cd $COLOR_DOODLE_DIR
npm install
npm run build
cd $MUSIC_PLAYER_DIR
npm install
npm run build
echo '==========[ Restarting supervisor ]=========='
sudo service supervisor restart
echo ''
echo '==========[ Web server should be back online now... ]=========='
echo ''
echo '==========[ Collecting static files ]=========='
$PYTHON $BASEDIR/manage.py collectstatic $PROD_SETTINGS --noinput --ignore=node_modules
echo ''
echo '==========[ Deploy Complete! ]=========='
echo ''