-
Notifications
You must be signed in to change notification settings - Fork 3
/
make-gui.sh
executable file
·75 lines (63 loc) · 1.52 KB
/
make-gui.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -eu -o pipefail
[ -z ${DEBUG-} ] || set -x
m() {
## Usage# m "$MESSAGE"
printf "[- INFO --- ] $1\n"
}
err() {
## Usage (w exit) # mkdir "$DIR" || err 'cannot create dir' 1
## Usage (wo exit) # mkdir "$DIR" || err 'cannot create dir'
local message="$1"; shift
local exit_code="$1"; shift
[ -n "$message" ] && printf "[- ERR ---- ] $message\n" >&2
[ -n "$exit_code" ] && exit "$exit_code"
}
ergogen_build() {
local target="${1:-run}"
docker build \
--no-cache \
--target "${target}" \
-t ergogen-gui:latest \
-f Dockerfile.gui \
.
}
ergogen_run() {
docker run \
-it \
--rm \
--init \
--name ergogen-gui \
-p 3000:3000 \
-v $(pwd)/footprints:/ergogen-gui/node_modules/ergogen/src/footprints \
ergogen-gui:latest
}
ergogen_daemon() {
docker run \
-d \
--rm \
--init \
--name ergogen-gui \
-p 3000:3000 \
-v $(pwd)/footprints:/ergogen-gui/node_modules/ergogen/src/footprints \
ergogen-gui:latest
}
ergogen_update_footprints() {
docker exec -it ergogen-gui npm run build-ergogen
}
main() {
[ $# -eq 0 ] && err "available subcommands: build, run, daemon, sync" 2
local cmd="$1"; shift
case $cmd in
"build" | "run" | "daemon")
$"ergogen_$cmd" "$@"
;;
"sync")
ergogen_update_footprints
;;
*)
err "command $cmd is not supported" 3
;;
esac
}
main "$@"