forked from baidu/openrasp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-cloud.sh
executable file
·84 lines (62 loc) · 1.39 KB
/
build-cloud.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
#!/bin/bash
#
# Build our VUE frontend and golang api server
# Output to rasp-cloud.tar.gz
#
set -ex
function check_prerequisite()
{
npm=$(which npm)
go=$(which go)
if [[ -z "$npm" ]]; then
echo NodeJS is required to build VUE frontend
exit
fi
if [[ -z "$go" ]]; then
echo GO binary is required to build backend API server
exit
fi
}
function repack()
{
tar=$1
name=$2
output=$3
git_root=$(dirname $(readlink -f "$output"))
rm -rf tmp "$output"
mkdir tmp
tar xf "$tar" -C tmp
# 安装默认插件
mkdir tmp/resources
rm -rf tmp/dist
cp "$git_root"/plugins/official/plugin.js tmp/resources
mv "$git_root"/rasp-vue/dist tmp
mv tmp "$name"
tar --numeric-owner --owner=0 --group=0 -czf "$output" "$name"
# 删除临时文件,以前的包
rm -rf "$name" "$tar"
}
function build_cloud()
{
cd cloud
export GOPATH=$(pwd)
export PATH=$PATH:$GOPATH/bin
if [[ -z "$NO_BEE_INSTALL" ]]; then
go get -u github.com/beego/bee
fi
cd src/rasp-cloud
bee pack -exr=vendor
repack rasp-cloud.tar.gz rasp-cloud-$(date +%Y-%m-%d) ../../../rasp-cloud.tar.gz
}
function build_vue()
{
cd rasp-vue
if [[ -z "$NO_NPM_INSTALL" ]]; then
npm ci --unsafe-perm
fi
npm run build
}
cd "$(dirname "$0")"
check_prerequisite
(build_vue)
(build_cloud)