-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·65 lines (48 loc) · 1.4 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
#!/bin/bash
##
## A portable script to deploy docker compose based projects
##
## Expects:
## 1. HOST has docker compose
## 2. HOST uses nginx as reverse proxy with virtual hosts in
## /etc/nginx/virtual-hosts
## 3. Project has a self contained docker-compose.yml
##
## WARNING:
## while this file seemingly resides in the services.kindstudios.gr repo
## it is being used by many other projects via creative symlinking. Namely:
## * status.devices.kindstudios.gr
## * styling.services.kindstudios.gr
## * and probably many others!
##
cd $( dirname $0 )
PRJ=$( basename $PWD )
HOST=hermes.devices.kindstudios.gr
[ $# -gt 0 ] && [ "$1" = "--only-nginx" ] && ONLY_NGINX=true || ONLY_NGINX=false
echo "Syntax:
$0 --only-nginx
Deploying: $PRJ
"
# build
docker-compose build
docker-compose push
# use ./* to skip hidden files like .git
ssh ${HOST} mkdir -p /opt/web/${PRJ}
scp docker-compose.yml ${PRJ}.conf ${HOST}:/opt/web/${PRJ}/
rsync -avuz ./assets/ ${HOST}:/opt/web/${PRJ}/assets
if $ONLY_NGINX
then
INSTALL="cd /opt/web/$PRJ &&
mv ${PRJ}.conf /etc/nginx/virtual-hosts/ &&
systemctl restart nginx"
else
docker-compose build
docker-compose push
INSTALL="cd /opt/web/$PRJ &&
chown -R 82 assets
docker-compose pull &&
docker-compose up -d --force-recreate &&
mv ${PRJ}.conf /etc/nginx/virtual-hosts/ &&
systemctl restart nginx"
fi
ssh $HOST "bash -c '$INSTALL'"