-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·94 lines (80 loc) · 1.67 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
#!/bin/bash
set -e
function generate_cert {
./generate-cert.sh
}
function clean_proto {
rm -f proto/client/* proto/server/*
}
function clean_static {
rm -f frontend/static/*
}
function build_proto {
# the /tmp path is for CI only
protoc -I. -I/tmp/protobuf/include -Ivendor/ ./proto/web.proto \
--go_out=plugins=grpc:$GOPATH/src
}
function build_static {
mkdir -p frontend/static
# Do the static frontend build, unless if parcel is running.
# We need the -f option here, since parcel is a node process.
if ! pgrep -f "parcel" > /dev/null ; then
# we could pass --public-url to parcel build
(cd ui && parcel build index.html)
fi
cp ui/dist/* frontend/static/
# TODO(cm) move these steps into assets_generate.go
mkdir -p frontend/bundle
touch frontend/bundle/bundle.go
(cd frontend && go run assets_generate.go)
}
function build_all {
if [ ! -f ./key.pem ]; then
generate_cert
fi
clean_proto
build_proto
clean_static
build_static
go build
build_container
}
function build_default {
go build
}
function build_container {
if [ ! -f ./co-chair ]; then
go build
fi
cp co-chair docker
pushd docker
bash container.sh
popd
}
case "$1" in
all)
build_all
;;
clean)
clean_static
clean_proto
;;
container)
build_container
;;
static)
clean_static
build_static
;;
proto)
clean_proto
build_proto
;;
help)
echo "Usage:"
echo " ./build.sh [help|clean|all|static|proto]"
;;
*)
build_default
;;
esac