forked from SeldonIO/seldon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_build_and_push_images.sh
87 lines (74 loc) · 2.11 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
#!/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
echo "Files changed in python folder:"
git --no-pager diff --exit-code --name-only origin/master python
PYTHON_MODIFIED=$?
if [[ $PYTHON_MODIFIED -gt 0 ]]; then
(cd wrappers/s2i/python/build_scripts \
&& ./build_all_local.sh \
&& ./push_all.sh)
PYTHON_EXIT_VALUE=$?
else
echo "SKIPPING PYTHON IMAGE BUILD..."
PYTHON_EXIT_VALUE=0
fi
echo "Files changed in operator folder:"
git --no-pager diff --exit-code --name-only origin/master operator
OPERATOR_MODIFIED=$?
if [[ $OPERATOR_MODIFIED -gt 0 ]]; then
make \
-C operator \
docker-build \
docker-push
OPERATOR_EXIT_VALUE=$?
else
echo "SKIPPING OPERATOR IMAGE BUILD..."
OPERATOR_EXIT_VALUE=0
fi
echo "Files changed in engine folder:"
git --no-pager diff --exit-code --name-only origin/master engine
ENGINE_MODIFIED=$?
if [[ $ENGINE_MODIFIED -gt 0 ]]; then
make \
-C testing/scripts \
build_protos
make \
-C engine \
build_image \
push_to_registry
ENGINE_EXIT_VALUE=$?
else
echo "SKIPPING ENGINE IMAGE BUILD..."
ENGINE_EXIT_VALUE=0
fi
#######################################
# 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
exit $((${PYTHON_EXIT_VALUE} \
+ ${OPERATOR_EXIT_VALUE} \
+ ${ENGINE_EXIT_VALUE}))