-
Notifications
You must be signed in to change notification settings - Fork 2
/
compose.sh
executable file
·50 lines (47 loc) · 1.01 KB
/
compose.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
#!/bin/bash
# Usage using comment after ')' for each argument
usage(){ echo "$0 usage:" && grep " .)\ #" $0; exit 0;}
dc="docker compose"
# getopts
while getopts "bdmshu" arg; do
case $arg in
s) # Stop Docker
s="stop"
;;
d) # Down Docker
d="down"
;;
m) # Add minio '-f docker-compose.yml -f docker-compose.minio.yml'
m="-f docker-compose.yml -f docker-compose.minio.yml"
;;
u) # Docker compose up
u="up"
;;
b) # Start Docker with --build flag
b="--build"
;;
h | *) # Display help
usage
exit 0
;;
esac
done
if [[ ! -z ${s} && ! -z ${m} ]]
then
cmd="$dc $m $s"
elif [ ! -z ${s} ]
then
cmd="$dc $s"
elif [[ ! -z ${d} && ! -z ${m} ]]
then
cmd="$dc $m $d"
elif [ ! -z ${d} ]
then
cmd="$dc $d"
elif [[ ! -z ${m} || ! -z ${b} ]]
then
cmd="$dc $m up $b"
fi
[ $# -eq 0 ] && cmd="$dc up"
echo "$cmd"
eval "$cmd"