-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·40 lines (34 loc) · 1.22 KB
/
start.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
#!/bin/bash
function usage () {
[[ -n "$2" ]] && echo "$(basename $0): $2" >&2
echo "$(basename $0) -e ENV [OPTIONS] | -h"
echo
echo "-h ................... print this message and exit"
echo "-d ................... print the configuration used and exit"
echo "-e ENV ............... set environment to ENV (default: standalone)"
echo
echo "ENV:"
/bin/ls docker-compose.*.yml | sed 's/docker-compose\.\(.*\)\.yml/ - \1/g'
exit $1
}
OPT_COMMAND="up -d"
OPT_ENVIRONMENT="standalone"
while getopts "hde:" opt ; do
case "${opt}" in
h) usage ; exit ;;
d) OPT_COMMAND="config" ;;
e) OPT_ENVIRONMENT="${OPTARG}" ;;
*) usage 1 "error: unknown argument ${opt}" ; exit $? ;;
esac
done
shift $((OPTIND-1))
override=docker-compose.${OPT_ENVIRONMENT}.yml
if [[ -z "${override}" ]] ; then
usage 2 "error: missing mandatory argument: -e ENV"
fi
if [[ ! -r "${override}" ]] ; then
usage 3 "error: unknown file '${override}'"
fi
trap "docker rmi busybox" EXIT
docker run --rm --mount type=bind,source=${PWD}/src/common/custom-cont-init.d/master-install.sh,target=/master-install.sh busybox chown 0:0 /master-install.sh
docker-compose -f docker-compose.yml -f "${override}" ${OPT_COMMAND} $*