-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (75 loc) · 2.02 KB
/
Makefile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! make
deployDir='/mnt/ext250/web-apps/cbg.rik.ai'
login=root@rik.ai
login:
ssh ${login}
# just run this once
nginxSetup:
scp devops/cbg.rik.ai.nginx ${login}:/etc/nginx/sites-enabled/
# echo "testing config:"
ssh ${login} "sudo nginx -t"
# echo "restarting nginx"
ssh ${login} "sudo nginx -t && sudo systemctl restart nginx"
firstDeploy:
# make deploy dir
ssh ${login} "mkdir -p ${deployDir}"
pm2first:
ssh ${login} "cd ${deployDir} && NODE_ENV=production pm2 --name=cbg start dist/index.js"
pm2restart:
ssh ${login} "pm2 restart cbg"
pm2logs:
ssh ${login} "pm2 logs cbg"
clean:
rm -rf client/build
rm -rf server/build
rm -rf server/dist
# image files can have wrong permissions when copied from internet
fixPermissions:
# directories 755
find server/cdn -type d -exec chmod 755 {} \;
# files 644
find server/cdn -type f -name '*.jpg' -exec chmod 644 {} \;
find server/cdn -type f -name '*.png' -exec chmod 644 {} \;
buildClient: clean fixPermissions
cd client && npm run build
buildServer:
cd server && npm run build
# build client last as it adds files
buildBoth: buildServer buildClient
copyClient:
cp -r client/build server
prep: clean buildBoth copyClient
# --exclude src \
sync:
rsync -avi --delete \
--exclude .git \
--exclude coverage \
--exclude ./src/* \
--exclude *.ts \
--exclude .vscode \
--exclude .build \
--exclude .github \
--exclude coverage \
--exclude logs/*.log \
--exclude docs \
--exclude asylum-illustrations \
server/ ${login}:${deployDir}
echo "done"
syncCdn: fixPermissions
rsync -avi --delete \
--exclude .git \
server/cdn/ "${login}:${deployDir}/cdn"
echo "done"
deploy: prep sync pm2restart
# just server code
quickDeploy: buildServer sync pm2restart
# run on the target machine
renewCert:
certbot certonly -n -d cbg.rik.ai --nginx
sudo systemctl restart nginx
tailNginx:
ssh ${login} "tail -f /var/log/nginx/*log"
testDeploy:
curl http://cbg.rik.ai/assets/items/chest-closed.png
testLocalImages:
curl http://localhost:33010/cdn/assets/items/key.png