-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerBuild.sh
executable file
·50 lines (40 loc) · 1.29 KB
/
dockerBuild.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
#!/bin/bash
GIT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null)
VERSION="unknown"
echo "Got tag:\"${GIT_TAG}\""
if [ -z $GIT_TAG ]; then
GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
echo "Got branch:\"${GIT_BRANCH}\""
if [ "$GIT_BRANCH" == "master" ]; then
VERSION="latest"
fi
if [ "$TRAVIS_BRANCH" == "master" ] ; then
VERSION="latest"
fi
else
VERSION=$GIT_TAG
fi
set -e
echo "---------------------"
echo " Building khostdns "
echo "---------------------"
docker run --rm -e VERSION=${VERSION} -e HOME=/tmp -u $(id -u ${USER}):$(id -g ${USER}) -v "$PWD":/go/khostdns -w /go/khostdns golang:1.14 \
./build.sh
echo ""
echo "---------------------"
echo "Building khostdns Container version: ${VERSION}"
echo "---------------------"
DTAG="premiereglobal/khostdns:${VERSION}"
docker build . -t ${DTAG}
echo "---------------------"
echo "Created Tag ${DTAG}"
echo "---------------------"
if [[ ${TRAVIS} && "${VERSION}" != "unknown" && -n $DOCKER_USERNAME && -n $DOCKER_PASSWORD ]]; then
echo "Pushing docker image: ${DTAG}"
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
docker push ${DTAG}
#elif [[ ${TRAVIS} && -z $DOCKER_USERNAME ]]; then
# echo "No Docker user set"
#elif [[ ${TRAVIS} && -z $DOCKER_PASSWORD ]]; then
# echo "No Docker user set"
fi