-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-build.sh
executable file
·33 lines (28 loc) · 1.22 KB
/
docker-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
#!/bin/bash
NO_CACHE=""
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
VERSION=$(git describe --tags --abbrev=0)
GIT_BRANCH=$(git symbolic-ref --short HEAD)
echo
echo "/######################################################################/"
echo " Build new image terrabrasilis/general-fires-data-task-$GIT_BRANCH:$VERSION "
echo "/######################################################################/"
echo
docker build $NO_CACHE -t "terrabrasilis/general-fires-data-task-$GIT_BRANCH:$VERSION" --build-arg VERSION="$VERSION" -f env-scripts/Dockerfile .
# send to dockerhub
echo
echo "The building was finished! Do you want sending these new images 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 images!"
docker push "terrabrasilis/general-fires-data-task-$GIT_BRANCH:$VERSION"
fi