-
Notifications
You must be signed in to change notification settings - Fork 120
/
build.include
executable file
·73 lines (66 loc) · 1.73 KB
/
build.include
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
#!/bin/sh
# Copyright (c) 2016 Codenvy, S.A.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Florent Benoit - Initial Implementation
set -e
set -u
IMAGE_ALIASES=${IMAGE_ALIASES:-}
skip_update() {
for i in "$@" ; do
if [ $i = "--skip-update" ]; then
echo "true"
exit 0
fi
done
echo "false"
}
get_tag() {
for i in "$@" ; do
if [ $i != "--skip-update" ]; then
echo $i
exit 0
fi
done
}
init() {
BLUE='\033[1;34m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
tmp=$(get_tag "$@")
if [ ! -z "$tmp" ]; then
TAG=$tmp
else
TAG="nightly"
echo "No tag provided, using nightly as default"
fi
}
build() {
DIR=$(cd "$(dirname "$0")"; pwd)
echo "Building Docker Image ${IMAGE_NAME} from $DIR directory with tag $TAG"
cd "${DIR}" && docker build -t ${IMAGE_NAME}:${TAG} .
if [ $? -eq 0 ]; then
printf "Build of ${BLUE}${IMAGE_NAME}:${TAG} ${GREEN}[OK]${NC}\n"
if [ ! -z "${IMAGE_ALIASES}" ]; then
for TMP_IMAGE_NAME in ${IMAGE_ALIASES}
do
docker tag ${IMAGE_NAME}:${TAG} ${TMP_IMAGE_NAME}:${TAG}
if [ $? -eq 0 ]; then
printf " /alias ${BLUE}${TMP_IMAGE_NAME}:${TAG}${NC} ${GREEN}[OK]${NC}\n"
else
printf "${RED}Failure when building docker image ${IMAGE_NAME}:${TAG}${NC}\n"
exit 1
fi
done
fi
printf "${GREEN}Script run successfully: ${BLUE}${IMAGE_NAME}:${TAG}${NC}\n"
else
printf "${RED}Failure when building docker image ${IMAGE_NAME}:${TAG}${NC}\n"
exit 1
fi
}