-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdeploy.sh
49 lines (35 loc) · 1.17 KB
/
deploy.sh
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
#! /bin/bash
# "Automation" of the API app deployment.
# * Sets up virtual env
# * Gets code from the `dev` branch
# * sets up environment vars
# * install dependencies
# * run migrations
# * restart server
# Create and activate virtual env
virtualenv --python=/usr/bin/python3 venv
source venv/bin/activate
curr_date=`date "+%Y-%m-%d_%H-%M-%S"`
# backup current version if it exists
[ -d State-TalentMAP-API-dev ] && mv State-TalentMAP-API-dev State-TalentMAP-API-dev-$curr_date
# get code
wget -O dev.zip https://github.com/MetaPhase-Consulting/State-TalentMAP-API/archive/dev.zip
unzip -o dev.zip
rm dev.zip
cd State-TalentMAP-API-dev
# copy env setup script
cp EXAMPLE_setup_environment.sh setup_environment.sh
# setup env
source setup_environment.sh
export DATABASE_URL='<DATABASE_URL>'
export DJANGO_LOG_DIRECTORY='/home/ec2-user/log/'
export DEPLOYMENT_LOCATION='/home/ec2-user/State-TalentMAP-API-dev/'
export FSBID_API_URL='http://dev.talentmap.fsbid.metaphasedev.com'
# install dependencies
pip install -r requirements.txt
python manage.py migrate
# Stop the server
pkill -f runserver
python manage.py runserver 0.0.0.0:8000 &>/dev/null &
echo "Deployment complete"
exit