-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmake.sh
executable file
·42 lines (35 loc) · 1.26 KB
/
make.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
#!/bin/bash
set -e
hash docker 2>/dev/null || {
echo "Docker not found. Please install."
exit 1
}
if [ -e build ]; then
if [ ! -e build/docker_build.txt ]; then
echo "Please remove build directory."
exit 1
fi
fi
mkdir -p build
touch build/docker_build.txt
if [[ -n "$UID" && -n "$USER" ]]; then
# run docker as current user for convenience
args="-u=$UID:$(id -g $USER)"
fi
# start a container in the background, just to make builds more responsive
docker ps -f name=cosmicos_build | grep -q cosmicos || {
docker run --rm --name cosmicos_build -v $PWD:/cosmicos paulfitz/cosmicos_builder src/prepare_node.sh
docker run -dit --rm $args --name cosmicos_build -v $PWD:/cosmicos -v /tmp/docker_npm:/.npm -v $PWD/node_modules_docker:/cosmicos/node_modules paulfitz/cosmicos_builder /bin/bash
}
# run our actual build command, finally
if [[ "$1" = "run" ]]; then
shift
docker exec -e VERBOSE=$VERBOSE cosmicos_build "$@"
elif [[ "$1" = "console" ]]; then
shift
docker exec -it -e VERBOSE=$VERBOSE cosmicos_build /bin/bash
elif [[ "$1" = "mocha" ]]; then
docker exec -e VERBOSE=$VERBOSE cosmicos_build node_modules/.bin/mocha tests/test_basics.ts
else
docker exec -e VERBOSE=$VERBOSE cosmicos_build src/make_without_docker.sh "$@"
fi