forked from SeldonIO/seldon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomino-build.sh
executable file
·91 lines (71 loc) · 2.76 KB
/
domino-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
#!/bin/bash
set -o nounset -o errexit -o pipefail
set -e
AUTO_TAG_FLAG=''
NO_PUSH_FLAG=''
TAG_ARG=''
while getopts 'ant:' flag; do
case "${flag}" in
a) AUTO_TAG_FLAG='true' ;;
n) NO_PUSH_FLAG='true' ;;
t) TAG_ARG="${OPTARG}" ;;
*)
echo "Unexpected option ${flag}"
exit 1
;;
esac
done
readonly AUTO_TAG_FLAG
readonly NO_PUSH_FLAG
readonly TAG_ARG
SELDON_REPO=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd "${SELDON_REPO}"
SOURCE_IMAGE_TAG="$(<version.txt)"
TARGET_GIT_REV_TAG="${SOURCE_IMAGE_TAG}-$(git rev-parse --short HEAD)"
TARGET_IMAGE_TAGS=("${TARGET_GIT_REV_TAG}")
BRANCH_NAME="$(git symbolic-ref --short --quiet HEAD || echo "")"
if [ -n "${BRANCH_NAME}" ]; then
TARGET_IMAGE_TAGS+=("${SOURCE_IMAGE_TAG}-${BRANCH_NAME}.latest")
fi
if [ -n "${TAG_ARG}" ]; then
TARGET_IMAGE_TAGS+=("${TAG_ARG}")
fi
GIT_HEAD_TAG="$(git describe --tags --exact-match HEAD 2> /dev/null || echo "")"
if [ -n "${AUTO_TAG_FLAG}" ] && [ -n "${GIT_HEAD_TAG}" ]; then
TARGET_IMAGE_TAGS+=("${GIT_HEAD_TAG}")
fi
echo -e "\n Building operator...\n"
cd "$SELDON_REPO/operator"
make docker-build
echo -e "\n Building executor...\n"
cd "$SELDON_REPO/executor"
make docker-build
cd "${SELDON_REPO}"
if [ -z "${NO_PUSH_FLAG}" ]; then
if [ -f ~/.docker/config.json ] && [ "$(cat ~/.docker/config.json | jq '.auths | has("quay.io")')" == "true" ]; then
echo -e "[Docker is already logged into quay.io, using existing credentials.]"
elif [ "${QUAY_USER:-missing}" != "missing" ] && [ "${QUAY_PASSWORD:-missing}" != "missing" ]; then
echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USER" --password-stdin quay.io
else
echo "Push to quay.io requires docker login, either run 'docker login quay.io' or set QUAY_USER and QUAY_PASSWORD before running this script."
exit 1
fi
for TARGET_IMAGE_TAG in "${TARGET_IMAGE_TAGS[@]}"
do
echo -e "\n Tagging operator..."
docker tag "seldonio/seldon-core-operator:${SOURCE_IMAGE_TAG}" "quay.io/domino/seldon-core-operator:${TARGET_IMAGE_TAG}"
echo -e " Tagged operator as ${TARGET_IMAGE_TAG}"
echo -e "\n Tagging executor..."
docker tag "seldonio/seldon-core-executor:${SOURCE_IMAGE_TAG}" "quay.io/domino/seldon-core-executor:${TARGET_IMAGE_TAG}"
echo -e " Tagged executor as ${TARGET_IMAGE_TAG}"
operator_target="quay.io/domino/seldon-core-operator:${TARGET_IMAGE_TAG}"
echo -e "\n Pushing operator..."
docker push "${operator_target}"
echo -e " *** Pushed operator to ${operator_target} *** "
executor_target="quay.io/domino/seldon-core-executor:${TARGET_IMAGE_TAG}"
echo -e "\n Pushing executor...\n"
docker push "${executor_target}"
echo -e " *** Pushed executor to ${executor_target} *** \n"
done
echo "${TARGET_GIT_REV_TAG}" > ~/.seldon-core-image-tag
fi