-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-aggregate.sh
executable file
·46 lines (40 loc) · 1.71 KB
/
build-aggregate.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
#!/bin/bash
NO_CACHE=""
# pass "silent" as first parameter when calling this script to skip questions
if [[ ! "$1" = "silent" ]]; then
echo "Do you want to build using docker cache from previous build? Type yes to use cache." ; read BUILD_CACHE
if [[ ! "$BUILD_CACHE" = "yes" ]]; then
echo "Using --no-cache to build the image."
echo "It will be slower than use docker cache."
NO_CACHE="--no-cache"
else
echo "Using cache to build the image."
echo "Nice, it will be faster than use no-cache option."
fi
fi
VERSION=$(git describe --tags --abbrev=0)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# if current branch isn't master then change version tag
if [[ ! "${BRANCH}" = "master" ]]; then
TAG_VERSION="${VERSION}.${BRANCH}.rc"
else
TAG_VERSION=${VERSION}
fi
echo
echo "/######################################################################/"
echo " Build new image terrabrasilis/amazon-alert-aggregated:${TAG_VERSION} "
echo "/######################################################################/"
echo
docker build $NO_CACHE -t "terrabrasilis/amazon-alert-aggregated:${TAG_VERSION}" --build-arg VERSION=$VERSION --build-arg INDEX_FILE=deter-amazon-aggregated -f environment/Dockerfile .
# pass "silent" as first parameter when calling this script to skip questions
if [[ ! "$1" = "silent" ]]; then
# send to dockerhub
echo
echo "The building was finished! Do you want sending the new image to Docker HUB? Type yes to continue." ; read SEND_TO_HUB
if [[ ! "$SEND_TO_HUB" = "yes" ]]; then
echo "Ok, not send the images."
else
echo "Nice, sending the image!"
docker push "terrabrasilis/amazon-alert-aggregated:${TAG_VERSION}"
fi
fi