-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
66 lines (53 loc) · 1.55 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# This is a manual deployment script for ease of life. Would be much
# better if we have an auto deployment system like git hooks
# but I haven't been able to set it up yet
cd ~/website
# front end deployment
echo PULLING NEW FRONT END CODE...
cd front-end/
git checkout master
git pull
echo [OK]
echo BUILDING FRONT END CODE...
npm install
npm run build
echo [OK]
# back end deployment
echo PULLING NEW BACK END CODE...
cd ../back-end/
git checkout master
git pull
echo [OK]
echo UPDATING NGINX CONFIG...
cp ./tedxuwa_nginx.conf /etc/nginx/sites-available/default
sudo /etc/init.d/nginx restart
echo [OK]
echo UPDATING GUNICORN SYSTEMD CONFIG...
cp ./gunicorn.service /etc/systemd/system/gunicorn.service
sudo /etc/init.d/nginx restart
echo [OK]
# echo UPDATING CERTBOT HOOKS...
# cp ./scripts/certbot_prerenew.sh /etc/letsencrypt/renewal-hooks/pre
# cp ./scripts/certbot_postrenew.sh /etc/letsencrypt/renewal-hooks/post
# chmod +x /etc/letsencrypt/renewal-hooks/pre/certbot_prerenew.sh
# chmod +x /etc/letsencrypt/renewal-hooks/post/certbot_postrenew.sh
# echo [OK]
echo UPDATING DEPLOYMENT SCRIPT...
cp deploy.sh ../
echo [OK]
echo INSTALLING REQUIREMENTS...
source env/bin/activate
pip install -r requirements.txt
echo [OK]
echo COLLECTING STATIC FILES...
python manage.py collectstatic --noinput --clear
echo [OK]
echo RUNNING MIGRATIONS...
python manage.py migrate # migrate the database
echo [OK]
echo STARTING SERVER...
sudo systemctl daemon-reload
sudo systemctl restart nginx
sudo systemctl restart gunicorn
# https://code.djangoproject.com/ticket/19615