-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·41 lines (32 loc) · 891 Bytes
/
run.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
#!/usr/bin/env bash
# wrapper for docker-compose
# all arguments are passed to docker-compose up
set -eux -o pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
# stop the services and clean up docker images
function clean() {
set +e
if [ -z "${prog_args}" ] || [ -n "${prog_args/*-d*/}" ]; then
docker-compose down -v
fi
docker image prune -f
}
# set common compose args
function docker-compose() {
if [ "${!compose_args*}" = "compose_args" ] && [ ${#compose_args[@]} -gt 0 ]; then
command docker-compose "${compose_args[@]}" "${@}"
else
command docker-compose "${@}"
fi
}
prog_args="${*:-}"
trap clean exit
"${RUN:-true}" || exit 0
declare -a deps=(postgres)
test ${#deps[@]} -eq 0 || docker-compose pull "${deps[@]}"
docker-compose build --pull
if [ ${#} -gt 0 ]; then
docker-compose up -V "${@}"
else
docker-compose up -V
fi