-
Notifications
You must be signed in to change notification settings - Fork 11
/
shell.bash
111 lines (86 loc) · 1.94 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
appname="phalcon-docker-nginx"
host="user@host"
echo $1 $2
run() {
echo "docker run \
$env \
--name=$appname \
-p 8888:80 \
$mode \
--restart=unless-stopped $appname"
}
if [ $1 == "local" ]
then
env="-e ENV_PROD=0"
mode="-it"
if [ $2 == "deploy" ]
then
if [ $3 == "daemon" ]
then
mode="-d"
fi
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 == "shell" ]
then
docker exec -it $appname bash
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"
mode="-it"
if [ $2 == "deploy" ]
then
ssh -tt $host "mkdir $appname && cd $appname && sudo chmod 777 * -R"
rsync --progress --exclude-from '.deployignore' -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"
if [ $3 == "daemon" ]
then
mode="-d"
fi
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 == "shell" ]
then
docker exec -it $appname bash
fi
if [ $2 == "logs" ]
then
ssh -tt $host "docker logs -f $appname"
fi
fi