-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbin.sh
More file actions
executable file
·157 lines (126 loc) · 3.04 KB
/
bin.sh
File metadata and controls
executable file
·157 lines (126 loc) · 3.04 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
FILES_DIR=/semiot-platform
VENDOR_DOCKER_IMAGES=(
"mysql"
)
CUSTOM_DOCKER_IMAGES=(
"api-gateway"
"wamp-router"
"device-proxy-service"
"data-archiving-service"
"frontend"
"triplestore"
)
MAVEN_PROJECTS=(
"commons-namespaces"
"commons-rdf"
"commons-restapi"
"device-proxy-service"
"data-archiving-service"
"api-gateway"
)
function mvn_build() {
echo "building maven project $1"
pushd $1
mvn clean install -DskipTests=true
popd
}
function docker_build() {
echo "building docker image $1 as $2"
sudo docker build -t docker.semiot.ru/$1 $2
}
function stop_and_clean() {
echo "stopping and cleaning target directory $FILES_DIR"
sudo docker-compose kill && \
sudo docker-compose rm -f --all && \
sudo rm -rf $FILES_DIR/fuseki/ $FILES_DIR/felix-cache/ $FILES_DIR/tsdb/
exit $?
}
function start_and_logs() {
echo "starting docker-compose with logs"
sudo docker-compose up -d && \
sudo docker-compose logs -f
exit $?
}
function restart_image() {
echo "restarting image $1"
sudo docker-compose restart $1
}
function build_webui() {
echo "buildung webui files"
pushd api-gateway/src/main/websrc
npm run build
popd
}
function mvn_build_all() {
echo "building all maven projects"
build_webui
for prj in "${MAVEN_PROJECTS[@]}"
do
mvn_build $prj
done
}
function docker_build_all() {
echo "building all docker images"
echo "building vendor images.."
for image in "${VENDOR_DOCKER_IMAGES[@]}"
do
echo "building $image"
docker_build $image docker/$image
done
echo "building custom images.."
for image in "${CUSTOM_DOCKER_IMAGES[@]}"
do
echo "building $image"
docker_build $image $image
done
}
case "$1" in
"stop-and-clean")
stop_and_clean
;;
"start-and-logs")
start_and_logs
;;
"build-mvn")
if [ -z "$2" ];
then
mvn_build_all
else
mvn_build $2
fi
;;
"build-docker")
if [ -z "$2" ];
then
docker_build_all
else
docker_build $2 $2
fi
;;
"build-all")
mvn_build_all
docker_build_all
;;
"update-singe-image")
if [ -z "$2" ];
then
echo "update-single-image requires a second argument; do nothing"
exit 1
else
mvn_build $2
docker_build $2 $2
echo "done; now you should execute 'docker-compose restart IMAGE_NAME'" # echo maybe something else; did not test properly
fi
;;
"clean-deploy")
stop_and_clean
mvn_build_all
docker_build_all
start_and_logs
;;
*)
echo $1
echo $"Usage: $0 {stop-and-clean|start-and-logs|build-mvn (NAME)|build-docker (NAME)|build-all|update-single-image NAME|clean-deploy}"
exit 1
esac