-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
laradock.sh
54 lines (51 loc) · 1.31 KB
/
laradock.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
#!/bin/bash
cmd=$1
target=$2
realPath() {
[[ $1 =~ ^/ ]] && a=$1 || a=`pwd`/$1
while [ -h $a ]
do
b=`ls -ld $a|awk '{print $NF}'`
c=`ls -ld $a|awk '{print $(NF -2)}'`
[[ $b =~ ^/ ]] && a=$b || a=`dirname $c`/$b
done
echo $a
}
if [ "$cmd" == "up" ]; then
action="up -d workspace php-fpm nginx redis php-worker"
echo $action
if [ -n "$target" ]; then
action="up -d $target"
fi
elif [ "$cmd" == "build" ]; then
action="up --build -d workspace php-fpm nginx redis php-worker"
if [ -n "$target" ]; then
action="up --build -d $target"
fi
elif [ "$cmd" == "stop" ]; then
action="stop workspace php-fpm nginx redis php-worker"
if [ -n "$target" ]; then
action="stop $target"
fi
elif [ "$cmd" == "exec" ]; then
if [ -n "$target" ]; then
echo "must set container name"
else
action="exec $target bash"
fi
elif [ "$cmd" == "ew" ]; then
action="exec workspace bash"
elif [ "$cmd" == "ep" ]; then
action="exec php-fpm bash"
elif [ "$cmd" == "en" ]; then
action="exec nginx bash"
elif [ "$cmd" == "epw" ]; then
action="exec php-worker bash"
fi
binPath=$(cd `dirname $0`;pwd)/laradock
shPath=`realPath $binPath`
cd `dirname $shPath`
if [ -n "$action" ]; then
echo $action
docker-compose $action
fi