forked from jitsucom/jitsu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-build-configurator.sh
executable file
·102 lines (86 loc) · 3.09 KB
/
local-build-configurator.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
#!/usr/bin/env bash
ARM_BUILD='GOARCH=arm64'
AMD_BUILD='GOARCH=amd64'
GO_BUILD_PARAMS=''
arch_flag='amd'
docker_flag='true'
print_usage() {
echo "Jitsu Configurator Building CLI usage:"
echo "./local-build-configurator.sh --arch [amd, arm] --docker [true, false]"
echo " "
echo "options:"
echo "-h, --help show brief help"
echo "-a, --arch specify an architecture for builg go:"
echo " -a amd: (default) build go with GOARCH=amd64 parameters for x86"
echo " -a arm: build go with GOARCH=arm64 parameters for arm"
echo "-d, --docker specify should CLI build docker image or not:"
echo " -d true: (default) build binaries and docker image"
echo " -d false: build only binaries"
}
while test $# -gt 0; do
case "$1" in
-h|--help)
print_usage
exit 0
;;
-a|--arch)
shift
if test $# -gt 0; then
export arch_flag=$1
else
echo "default architecture: $arch_flag"
fi
shift
;;
-d|--docker)
shift
if test $# -gt 0; then
export docker_flag=$1
else
echo "default build docker: $docker_flag"
fi
shift
;;
*)
break
;;
esac
done
if [ "$arch_flag" == 'arm' ]
then
GO_BUILD_PARAMS="$ARM_BUILD"
else
GO_BUILD_PARAMS="$AMD_BUILD"
fi
echo ""
echo "============================================"
echo "= Building go Configurator backend... ="
echo "============================================"
echo ""
(cd configurator/backend; rm -rf build && make all GOBUILD_PREFIX="$GO_BUILD_PARAMS") || { echo 'Building go configurator backend failed' ; exit 1; }
echo ""
echo "============================================"
echo "= Building Configurator UI... ="
echo "============================================"
echo ""
(cd configurator/frontend; pnpm clean && pnpm i && CI=false ANALYTICS_KEYS='{"eventnative": "js.gpon6lmpwquappfl07tuq.ka5sxhsm08cmblny72tevi", "sentry": "https://[email protected]/6365760"}' pnpm build) || { echo 'Building Configurator UI failed' ; exit 1; }
echo ""
echo "============================================"
echo "= Packaging Configurator... ="
echo "============================================"
echo ""
(cd configurator; rm -rf build/dist && mkdir -p build/dist/web; cp -r frontend/main/build/* build/dist/web/; cp backend/build/dist/* build/dist/) || { echo 'Packaging UI failed' ; exit 1; }
if [ "$docker_flag" == 'true' ]
then
echo ""
echo "============================================"
echo "= Building jitsucom/configurator docker... ="
echo "============================================"
echo ""
docker build -t jitsucom/configurator -f configurator-release.Dockerfile --build-arg dhid=jitsucom . || { echo 'Building jitsucom/configurator docker failed' ; exit 1; }
fi
echo ""
echo "============================================"
echo "= SUCCESSFUL BUILD ="
echo "============================================"
echo ""