-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-dev-helper.sh
executable file
·61 lines (52 loc) · 1.68 KB
/
docker-dev-helper.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
55
56
57
58
59
60
61
#!/bin/bash
if [ "$1" = "--up" ]; then
if [ "$2" = "-d" ]; then
docker-compose -f 'docker-compose.dev.yml' up -d
else
docker-compose -f 'docker-compose.dev.yml' up
fi
fi
if [ "$1" = "--migrate" ]; then
declare -fx _Migrate_Method
_Migrate_Method() {
docker-compose -f 'docker-compose.dev.yml' exec -T app yarn db:migrate:test:docker
}
( _Migrate_Method; )
ERROR_CODE=$?
echo $ERROR_CODE
if [[ $ERROR_CODE -eq 0 ]]; then
exit 0;
else
exit 1;
fi
fi
if [ "$1" = "--test" ]; then
declare -fx _Test_Method
_Test_Method() {
docker-compose -f 'docker-compose.dev.yml' exec -T app yarn env-cmd -f ./env/test.docker.env jest --runInBand --ci
}
( _Test_Method; )
ERROR_CODE=$?
echo $ERROR_CODE
if [[ $ERROR_CODE -eq 0 ]]; then
exit 0;
else
exit 1;
fi
fi
if [ "$1" = "--bash" ]; then
docker-compose -f 'docker-compose.dev.yml' up --no-start
docker-compose -f 'docker-compose.dev.yml' start # ensure we are started, handle also allowed to be consumed by vscode
docker-compose -f 'docker-compose.dev.yml' exec app bash
fi
if [ "$1" = "--halt" ]; then
docker-compose -f 'docker-compose.dev.yml' stop
fi
if [ "$1" = "--rebuild" ]; then
docker-compose -f 'docker-compose.dev.yml' up -d --force-recreate --no-deps --build app
fi
if [ "$1" = "--destroy" ]; then
docker-compose -f 'docker-compose.dev.yml' down --rmi local -v --remove-orphans
fi
[ -n "$1" -a \( "$1" = "--up" -o "$1" = "--bash" -o "$1" = "--halt" -o "$1" = "--rebuild" -o "$1" = "--destroy" \) ] \
|| { echo "usage: $0 --up | --halt | --rebuild | --destroy" >&2; exit 1; }