-
Notifications
You must be signed in to change notification settings - Fork 4
/
start
executable file
·31 lines (23 loc) · 917 Bytes
/
start
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
#!/bin/bash
PWD="$( cd "$(dirname "$0")" || exit 1 ; pwd -P )"
LOG_FILE="$PWD/$(date +%Y%m%d%H%M%S).log"
export COMPOSE_PROJECT_NAME='pgrst-dev'
export COMPOSE_FILE="$PWD/base/docker-compose.yml"
export TOOL_COMPOSE_FILE="$PWD/tools/$1/docker-compose.yml"
RUNNING="$(docker-compose ps -q | wc -l)"
function on_exit {
docker-compose logs --no-color --timestamps | sort -k3 > "$LOG_FILE"
docker-compose down
}
case "$1" in
('')
[[ "$RUNNING" -ne 0 ]] && echo 'Containers are already running' && exit 1
trap "on_exit" EXIT && docker-compose up --build ;;
("with-nothing")
docker-compose down --volumes --rmi all --remove-orphans ;;
("down")
docker-compose down ;;
(*)
[[ "$RUNNING" -eq 0 ]] && echo 'No containers running. Run this script without arguments to start them.' && exit 1
docker-compose -f "$TOOL_COMPOSE_FILE" run --rm --service-ports "$1" ;;
esac