forked from SeldonIO/seldon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_build_and_push_images.sh
executable file
·245 lines (217 loc) · 5.82 KB
/
ci_build_and_push_images.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# FIRST WE START THE DOCKER DAEMON
service docker start
# the service can be started but the docker socket not ready, wait for ready
WAIT_N=0
while true; do
# docker ps -q should only work if the daemon is ready
docker ps -q > /dev/null 2>&1 && break
if [[ ${WAIT_N} -lt 5 ]]; then
WAIT_N=$((WAIT_N+1))
echo "[SETUP] Waiting for Docker to be ready, sleeping for ${WAIT_N} seconds ..."
sleep ${WAIT_N}
else
echo "[SETUP] Reached maximum attempts, not waiting any longer ..."
break
fi
done
#######################################
# AVOID EXIT ON ERROR FOR FOLLOWING CMDS
set +o errexit
###########################################################
### Images that don't need build every time only on change
echo "Files changed in core builder folder:"
git --no-pager diff --exit-code --name-only origin/master core-builder/
CORE_BUILDER_MODIFIED=$?
if [[ $CORE_BUILDER_MODIFIED -gt 0 ]]; then
make -C core-builder/ build_docker_image push_to_registry
CORE_BUILDER_EXIT_VALUE=$?
if [[ $CORE_BUILDER_EXIT_VALUE -gt 0 ]]; then
echo "Prepackaged server build returned errors"
return 1
fi
else
echo "SKIPPING CORE BUILDER IMAGE BUILD..."
CORE_BUILDER_EXIT_VALUE=0
fi
echo "Files changed in python builder folder:"
git --no-pager diff --exit-code --name-only origin/master python-builder/
PYTHON_BUILDER_MODIFIED=$?
if [[ $PYTHON_BUILDER_MODIFIED -gt 0 ]]; then
make -C python-builder/ build_docker_image push_to_registry
PYTHON_BUILDER_EXIT_VALUE=$?
if [[ $PYTHON_BUILDER_EXIT_VALUE -gt 0 ]]; then
echo "Prepackaged server build returned errors"
return 1
fi
else
echo "SKIPPING PYTHON BUILDER IMAGE BUILD..."
PYTHON_BUILDER_EXIT_VALUE=0
fi
###########################################################
### Images that need build every time
function build_push_python {
(cd wrappers/s2i/python/build_scripts \
&& ./build_all.sh \
&& ./push_all.sh)
PYTHON_EXIT_VALUE=$?
}
function build_push_operator {
make \
-C operator \
docker-build \
docker-push \
docker-build-redhat \
docker-push-redhat
OPERATOR_EXIT_VALUE=$?
}
function build_push_executor {
make \
-C executor \
docker-build \
docker-push \
docker-build-redhat \
docker-push-redhat
EXECUTOR_EXIT_VALUE=$?
}
function build_push_mock {
make \
-C examples/models/mean_classifier \
build \
push && \
make \
-C testing/docker/echo-model \
build_image \
push_image && \
make \
-C testing/docker/fixed-model \
build_images \
push_images
MOCK_MODEL_EXIT_VALUE=$?
}
function build_push_alibi_detect {
make \
-C components/alibi-detect-server \
docker-build \
docker-push
ALIBI_DETECT_EXIT_VALUE=$?
}
function build_push_sklearnserver {
make \
-C servers/sklearnserver \
build \
push
SKLEARN_EXIT_VALUE=$?
}
function build_push_mlflowserver {
make \
-C servers/mlflowserver \
build \
push
MLFLOW_EXIT_VALUE=$?
}
function build_push_xgboostserver {
make \
-C servers/xgboostserver \
build \
push
XGBOOST_EXIT_VALUE=$?
}
function build_push_tfproxy {
make \
-C servers/tfserving_proxy \
build \
push
TFPROXY_EXIT_VALUE=$?
}
function build_push_alibi_explainer {
make \
-C components/alibi-explain-server \
docker-build \
docker-push
EXPLAIN_EXIT_VALUE=$?
}
function build_push_rclone_storage_initializer {
make \
-C components/rclone-storage-initializer \
docker-build \
docker-push
RCLONE_STORAGE_INITIALIZER_EXIT_VALUE=$?
}
function build_push_mab {
make \
-C components/routers/epsilon-greedy \
build \
push
MAB_EXIT_VALUE=$?
}
function build_push_keras_cifar10 {
make \
-C examples/models/keras_cifar10 \
build \
push
CIFAR10_EXIT_VALUE=$?
}
function build_push_lgbm {
make \
-C examples/models/lightgbm_custom_server \
build \
push
LGBM_EXIT_VALUE=$?
}
build_push_python
build_push_operator
build_push_executor
build_push_mock
build_push_alibi_detect
build_push_sklearnserver
build_push_mlflowserver
build_push_xgboostserver
build_push_tfproxy
build_push_alibi_explainer
build_push_rclone_storage_initializer
build_push_mab
build_push_keras_cifar10
build_push_lgbm
#######################################
# EXIT STOPS COMMANDS FROM HERE ONWARDS
set -o errexit
# CLEANING DOCKER
docker ps -aq | xargs -r docker rm -f || true
service docker stop || true
# NOW THAT WE'VE CLEANED WE CAN EXIT ON TEST EXIT VALUE
echo "PYTHON_EXIT_VALUE $PYTHON_EXIT_VALUE"
echo "OPERATOR_EXIT_VALUE $OPERATOR_EXIT_VALUE"
echo "EXECUTOR_EXIT_VALUE $EXECUTOR_EXIT_VALUE"
echo "MOCK_MODEL_EXIT_VALUE $MOCK_MODEL_EXIT_VALUE"
echo "ALIBI_DETECT_EXIT_VALUE $ALIBI_DETECT_EXIT_VALUE"
echo "SKLEARN_EXIT_VALUE $SKLEARN_EXIT_VALUE"
echo "MLFLOW_EXIT_VALUE $MLFLOW_EXIT_VALUE"
echo "XGBOOST_EXIT_VALUE $XGBOOST_EXIT_VALUE"
echo "TFPROXY_EXIT_VALUE $TFPROXY_EXIT_VALUE"
echo "RCLONE_STORAGE_INITIALIZER_EXIT_VALUE $RCLONE_STORAGE_INITIALIZER_EXIT_VALUE"
echo "MAB_EXIT_VALUE $MAB_EXIT_VALUE"
echo "CIFAR10_EXIT_VALUE $CIFAR10_EXIT_VALUE"
echo "LGBM_EXIT_VALUE $LGBM_EXIT_VALUE"
echo "CORE_BUILDER_EXIT_VALUE $CORE_BUILDER_EXIT_VALUE"
echo "PYTHON_BUILDER_EXIT_VALUE $PYTHON_BUILDER_EXIT_VALUE"
echo "EXPLAIN_EXIT_VALUE $EXPLAIN_EXIT_VALUE"
exit $((${PYTHON_EXIT_VALUE} \
+ ${OPERATOR_EXIT_VALUE} \
+ ${EXECUTOR_EXIT_VALUE} \
+ ${MOCK_MODEL_EXIT_VALUE} \
+ ${ALIBI_DETECT_EXIT_VALUE} \
+ ${SKLEARN_EXIT_VALUE} \
+ ${MLFLOW_EXIT_VALUE} \
+ ${XGBOOST_EXIT_VALUE} \
+ ${TFPROXY_EXIT_VALUE} \
+ ${RCLONE_STORAGE_INITIALIZER_EXIT_VALUE} \
+ ${MAB_EXIT_VALUE} \
+ ${CIFAR10_EXIT_VALUE} \
+ ${LGBM_EXIT_VALUE} \
+ ${CORE_BUILDER_EXIT_VALUE} \
+ ${PYTHON_BUILDER_EXIT_VALUE} \
+ ${EXPLAIN_EXIT_VALUE}))