forked from rubyboy/nginx-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·73 lines (56 loc) · 1.82 KB
/
build
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
#!/bin/bash
set -o pipefail
set -e
. scripts/common.sh
command=$1
# ensure a supported command
commands=(run tests deps clean)
if [[ ! ${commands[*]} =~ "$command" ]]; then
echo "${cyan}Unsupported command. Try:${no_color}"
echo "run [NAME]: build and run backend and the specified proxy container and report back the proxy's URL"
echo "tests: run the integration tests, building and running all necessary containers"
echo "deps: build only Lua script dependencies"
echo "clean: stop/delete all running containers and remove all images"
fi
if [[ "$command" == "run" ]]; then
run_proxy_name=${2:-default}
if [[ ! -d "hosts/proxy/${run_proxy_name}" ]]; then
echo "Not a valid proxy container to run: $run_proxy_name"
exit 1
fi
fi
commands=(run tests deps)
if [[ ${commands[*]} =~ "$command" ]]; then
# build Lua script dependencies
bash scripts/build_deps.sh
fi
if [[ "$command" == "run" ]]; then
# run backend container
sh scripts/run_backend.sh
# build proxy base image
sh scripts/build_proxy_base_image.sh
# run specified proxy container
sh scripts/run_proxy_container.sh $run_proxy_name
# report URL to proxy container
echo "${cyan}Proxy:${no_color}"
echo curl http://$(boot2docker ip)
fi
if [[ "$command" == "tests" ]]; then
echo "${cyan}Running integration tests:${no_color}"
cd test
# make sure npm packages are installed
npm install
# run tests
npm test
cd ..
fi
if [[ "$command" == "clean" ]]; then
# shut down all proxy containers
for proxy_dir in hosts/proxy/*; do
[[ -d "${proxy_dir}" ]] || continue # if not a directory, skip
proxy_name="$(basename $proxy_dir)"
sh scripts/stop_proxy_container.sh $proxy_name
done
# shut down backend container
sh scripts/stop_backend.sh
fi