-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.sh
executable file
·79 lines (68 loc) · 2.08 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
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
DOCKERHUB_USERNAME="edgargevorgyan"
UCL_USERNAME="egevorgyan"
BUILD="false"
CMD="null"
function usage() {
echo "deployment of ErasMail on the INGI VM"
echo ""
echo "./deploy.sh (up|down)"
echo "\t-h --help"
echo "\t--build|-b"
echo "\t--dockerhub-username=$DOCKERHUB_USERNAME"
echo "\t--ucl-username=$UCL_USERNAME"
echo ""
}
while [ "$1" != "" ]; do
case $1 in
up|down)
CMD=$1
shift 1
;;
--build|-b)
BUILD="true"
shift 1
;;
--ucl-username)
DOCKERHUB_USERNAME=$2
shift 2
;;
--dockerhub-username)
UCL_USERNAME=$2
shift 2
;;
-h | --help )
usage
exit
;;
* )
echo "ERROR: unknown parameter \"$1\""
usage
exit 1
;;
esac
done
if [ $CMD = "up" ]; then
echo "DOCKERHUB_USERNAME=$DOCKERHUB_USERNAME" > .env
if $BUILD; then
npm --prefix ./front-end/erasmail run build
docker build -t $DOCKERHUB_USERNAME/erasmail_nginx -f ./nginx/Dockerfile .
docker push $DOCKERHUB_USERNAME/erasmail_nginx
docker build -t $DOCKERHUB_USERNAME/erasmail_web ./back-end/erasmail
docker push $DOCKERHUB_USERNAME/erasmail_web
fi
scp ./.env* [email protected]:~
scp ./docker-compose.prod.yml [email protected]:~
ssh [email protected] "
scp ~/.env* [email protected]:~
scp ~/docker-compose.prod.yml [email protected]:~/
rm .env* docker-compose.prod.yml
ssh [email protected] 'docker-compose -f docker-compose.prod.yml pull; docker-compose -f docker-compose.prod.yml up --no-build -d'
"
elif [ $CMD = "down" ]; then
ssh [email protected] "
ssh [email protected] 'docker-compose -f docker-compose.prod.yml down --remove-orphans'
"
else
echo "Nothing to do!"
fi