-
Notifications
You must be signed in to change notification settings - Fork 1
/
shell.bash
86 lines (70 loc) · 1.38 KB
/
shell.bash
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
#!/bin/bash
appname="mongoose-skeleton"
host="localhost"
echo $1 $2
run() {
echo "docker run \
$env \
$cond \
--name=$appname \
-p 1212:1212 \
-d \
--restart=unless-stopped $appname"
}
if [ $1 == "local" ]
then
env="-e ENV_PROD=0"
cond="--net='host'"
if [ $2 == "deploy" ]
then
docker build -t $appname .
docker stop $appname
docker rm $appname
eval $(run)
fi
if [ $2 == "stop" ]
then
docker stop $appname
fi
if [ $2 == "exec" ]
then
docker exec -it $appname $3
fi
if [ $2 == "start" ]
then
docker start $appname
fi
if [ $2 == "logs" ]
then
docker logs -f $appname
fi
fi
if [ $1 == "remote" ]
then
env="-e ENV_PROD=1"
if [ $2 == "deploy" ]
then
ssh -tt $host "mkdir -p $appname && cd $appname && sudo chmod 777 * -R"
rsync --progress --exclude-from 'deploy.exclude' -avz -e "ssh" . $host:$appname
ssh -tt $host "cd $appname && docker build -t $appname ."
ssh -tt $host "cd $appname && docker stop $appname"
ssh -tt $host "cd $appname && docker rm $appname"
ssh -tt $host "cd $appname && $(run)"
fi
if [ $2 == "stop" ]
then
ssh -tt $host "docker stop $appname"
fi
if [ $2 == "exec" ]
then
ssh -tt $host "docker exec -it $appname $3"
fi
if [ $2 == "start" ]
then
ssh -tt $host "cd $appname && docker start $appname"
fi
if [ $2 == "logs" ]
then
ssh -tt $host "docker logs -f $appname"
fi
fi