-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild_web.sh
executable file
·52 lines (40 loc) · 1.15 KB
/
build_web.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
#!/bin/bash
set -e
tmpdir="/tmp/"
dockerfile="Dockerfile-web-builder"
for runtime in podman docker; do
cmd=$(command -v $runtime)
if [[ "$cmd" != "" ]] && $cmd ps &> /dev/null; then
if [[ "$runtime" == "docker" ]]; then
change_owner_docker="chown -R $(id -u):$(id -g) ./build/"
else
change_owner_docker="true"
fi
break
else
echo "Unable to use $runtime"
cmd=""
fi
done
if [[ "$cmd" != "" ]]; then
echo "Using: $cmd"
else
echo "No container runtime found!"
exit 1
fi
rm -rf ./web/build/
cat <<EOF > $tmpdir$dockerfile
FROM registry.access.redhat.com/ubi8/ubi-minimal
RUN microdnf module enable nodejs:20 && \
microdnf install npm python2 make gcc-c++
ADD web/*.json /web-build/
ADD web/public/ /web-build/public/
ADD web/src/ /web-build/src/
WORKDIR /web-build
CMD ["/bin/sh", "-c", "npm ci && npm run build && $change_owner_docker"]
EOF
$cmd build -t lunch-web-builder -f $tmpdir$dockerfile .
mkdir -p ./web/build
$cmd run --rm -v ./web/build/:/web-build/build/:Z --name lunch-web-builder lunch-web-builder
$cmd rmi -f lunch-web-builder
rm $tmpdir$dockerfile