-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_frontend_and_build_container.sh
executable file
·50 lines (41 loc) · 1.33 KB
/
compile_frontend_and_build_container.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
#!/bin/bash
#Not used by codefresh as I am using build container instead
#working directory is always templateservicename root
source ./_repo_vars.sh
GITROOT=$(pwd)
DOCKER_USERNAME=metcarob
VERSIONNUM=$(cat ./VERSION)
QUASARBUILDIMAGE="metcarob/docker-build-quasar-app:0.0.30"
#could be spa or pwa
QUASARBUILDMODE=pwa
docker image inspect ${DOCKER_USERNAME}/${DOCKER_IMAGENAME}:${VERSIONNUM}_localbuild > /dev/null
RES=$?
if [ ${RES} -eq 0 ]; then
docker rmi ${DOCKER_USERNAME}/${DOCKER_IMAGENAME}:${VERSIONNUM}_localbuild
RES2=$?
if [ ${RES2} -ne 0 ]; then
echo "Image exists and delete failed"
exit 1
fi
fi
docker run --rm --name docker_build_quasar_app --mount type=bind,source=${GITROOT}/frontend,target=/ext_volume ${QUASARBUILDIMAGE} -c "build_quasar_app /ext_volume ${QUASARBUILDMODE} \"local_build_${VERSIONNUM}\""
RES=$?
if [ ${RES} -ne 0 ]; then
exit 1
fi
if [ ! -d ${GITROOT}/frontend/dist/${QUASARBUILDMODE} ]; then
echo "ERROR - build command didn't create ${GITROOT}/frontend/dist/${QUASARBUILDMODE} directory"
cd ${GITROOT}
exit 1
fi
echo "Build docker container (VERSIONNUM=${VERSIONNUM})"
#This file does no version bumping
cd ${GITROOT}
eval docker build . -t ${DOCKER_USERNAME}/${DOCKER_IMAGENAME}:${VERSIONNUM}_localbuild
RES=$?
if [ ${RES} -ne 0 ]; then
echo ""
echo "Docker build failed"
exit 1
fi
exit 0