-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode-env
executable file
·55 lines (43 loc) · 1.19 KB
/
node-env
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
#!/bin/bash
COMMAND=$1
MAIN_CONTAINER="node"
FILE_NAME="node-env"
function usage () {
cat <<- END
Usage:
./$FILE_NAME [option]
Options
sh runs shell in a node-alpine container (default command)
node runs node in a node-alpine container. You can use additional arguments.
npm runs npm in a node-alpine container. You can use additional arguments.
npx runs npx in a node-alpine container. You can use additional arguments.
expo runs expo in a node-alpine container. You can use additional arguments.
yarn runs yarn in a node-alpine container. You can use additional arguments.
prod runs commands without attaching the code as volume. You can use additional arguments.
END
}
function err() {
echo $@ >&2
}
function run_node () {
CURRENT_UID=$(id -u):$(id -g) docker-compose run $MAIN_CONTAINER $@
}
case "$COMMAND" in
'')
run_node sh
;;
'sh'|'node'|'npm'|'yarn'|'npx'|"expo")
run_node $@
;;
'help'|'-h'|'--help')
usage
;;
'prod')
docker-compose -f docker-compose.prod.yml run $MAIN_CONTAINER ${@:2}
;;
*)
err "Not supported argument: \"$1\""
err "Use \"./$FILE_NAME --help\" for usage information"
exit 1
;;
esac