This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sh
executable file
·114 lines (101 loc) · 2.57 KB
/
build.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
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
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
WEBAPP_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${WEBAPP_DIR}
if [ $# -lt 1 ]
then
ACTION=default
else
ACTION=$1
shift
fi
DOCKER_CMD="docker"
# Ensure volume exists for node modules (avoid putting in
# filesystem because of OS differences)
${DOCKER_CMD} volume inspect webapp-node-modules &> /dev/null
rc=$?
if [ $rc -ne 0 ]
then
${DOCKER_CMD} volume create webapp-node-modules
fi
# make sure node_modules directory exsts (mount point)
mkdir -p app/node_modules
# Modify this if your distribution gets UID/GID differently
userId=$(id -u)
groupId=$(id -g)
build_tools() {
${DOCKER_CMD} build \
--ulimit nofile=65535:65535 \
--build-arg userId=${userId} \
--build-arg groupId=${groupId} \
-f Dockerfile-node \
-t localhost/webapp-build .
}
PORT=
## Ensure the tools/build image exists.
tools_image=$(docker images -q localhost/webapp-build 2>/dev/null)
if [ "$tools_image" == "" ]
then
build_tools
fi
case "$ACTION" in
tools)
# Force rebuild of tools/build image, clear node modules for future changes
${DOCKER_CMD} volume rm webapp-node-modules
build_tools
exit 0
;;
cert)
WEBAPP_CMD="/usr/local/bin/docker-build.sh cert"
;;
shell)
WEBAPP_CMD=/bin/bash
;;
serve)
WEBAPP_CMD="/usr/local/bin/docker-build.sh serve"
;;
build)
WEBAPP_CMD="/usr/local/bin/docker-build.sh build"
;;
test)
WEBAPP_CMD="/usr/local/bin/docker-build.sh test"
;;
all)
WEBAPP_CMD="/usr/local/bin/docker-build.sh all"
;;
final)
if [ ! -d ${WEBAPP_DIR}/app/dist ] || [ ! -f ${WEBAPP_DIR}/app/dist/index.html ]
then
echo "App hasn't been built, running '${BASH_SOURCE[0]} build' first"
${BASH_SOURCE[0]} build
fi
# Rebuild the webapp
${DOCKER_CMD} build -t gameontext/gameon-webapp .
echo
echo "Docker images: "
${DOCKER_CMD} images | grep webapp
exit 0
;;
* )
WEBAPP_CMD="/usr/local/bin/docker-build.sh default"
ACTION=default
esac
which podman 2>&1 >/dev/null
PODMAN_RC=$?
if [ "$PODMAN_RC" == "0" ];then
podman unshare chown "${userId}:${groupId}" $PWD/app
fi
if [ ! -f $PWD/app/.test-localhost-cert.pem ]; then
${DOCKER_CMD} run --rm -it \
--user="${userId}:${groupId}" \
-v $PWD/app:/app:Z \
localhost/webapp-build \
sh -x /usr/local/bin/docker-build.sh cert
fi
${DOCKER_CMD} run --rm --init -it \
--user="${userId}:${groupId}" \
--security-opt seccomp=docker/chromium.json \
-v $PWD/app:/app:Z \
-v webapp-node-modules:/app/node_modules:Z \
-p 9876:9876 \
localhost/webapp-build \
${WEBAPP_CMD}