-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.sh
More file actions
executable file
·104 lines (90 loc) · 2.54 KB
/
docker.sh
File metadata and controls
executable file
·104 lines (90 loc) · 2.54 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Nodejs package command
CMD_NPM="npm"
CMD_YARN="yarn"
# JS
CMD_JS_CONTAINER_SHELL="js-container-console"
CMD_JS_RUN="js-run"
# Koa.js
CMD_KOA_RUN="run-koa"
# Service
CMD_SERVICE_MANGODB="run-mangodb"
CMD_SERVICE_LOCALSTACK="run-localstack"
CMD_SERVICE_LOCALSTACK_CONSOLE="console-localstack"
CMD_SERVICE_MYSQL="run-mysql"
# https://stackoverflow.com/questions/5474732/how-can-i-add-a-help-method-to-a-shell-script
usage="
\033[1m$(basename "$0")\033[0m - JS
Options:
-h show detail description about how to use options and commands.
Commands:
Services:
\033[1m"$CMD_SERVICE_MANGODB"\033[0m
Run MangoDB server
\033[1m"$CMD_SERVICE_LOCALSTACK"\033[0m
Run Localstack server
\033[1m"$CMD_SERVICE_LOCALSTACK_CONSOLE"\033[0m
Localstack console
\033[1m"$CMD_SERVICE_MYSQL"\033[0m
Run MySQL server
NPM:
\033[1m"$CMD_NPM"\033[0m
Run npm command
\033[1m"$CMD_YARN"\033[0m
Run yarn command
JS:
\033[1m"$CMD_JS_CONTAINER_SHELL"\033[0m
Console of JS App container
Koa.js:
\033[1m"$CMD_KOA_RUN"\033[0m
Run Koa.js App container
"
seed=42
while getopts ':hs:' option; do
case "$option" in
h)
echo -e "$usage"
exit
;;
s)
seed=$OPTARG
;;
:)
printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?)
printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
PROJECT_NAME_JS='js-dev'
DOCKER_FILE="docker-compose.local.yml"
CMD_DOCKER=" docker-compose -f $DOCKER_FILE "
CMD_DOCKER_JS_PROJ_RUN=" $CMD_DOCKER run $PROJECT_NAME_JS"
Command="$1"
ARGUMENTS="$2"
$CMD_DOCKER build
if [ "$CMD_NPM" == "$Command" ]; then
$CMD_DOCKER_JS_PROJ_RUN $Command $ARGUMENTS
elif [ "$CMD_YARN" == "$Command" ]; then
$CMD_DOCKER_JS_PROJ_RUN $Command $ARGUMENTS
elif [ "$CMD_JS_CONTAINER_SHELL" == "$Command" ]; then
$CMD_DOCKER_JS_PROJ_RUN sh
elif [ "$CMD_JS_RUN" == "$Command" ]; then
$CMD_DOCKER up
elif [ "$CMD_KOA_RUN" == "$Command" ]; then
$CMD_DOCKER up koa-app
elif [ "$CMD_SERVICE_MANGODB" == "$Command" ]; then
$CMD_DOCKER up mongodb
elif [ "$CMD_SERVICE_LOCALSTACK" == "$Command" ]; then
$CMD_DOCKER up localstack
elif [ "$CMD_SERVICE_LOCALSTACK_CONSOLE" == "$Command" ]; then
$CMD_DOCKER exec localstack sh
elif [ "$CMD_SERVICE_MYSQL" == "$Command" ]; then
$CMD_DOCKER up db
fi