-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdockerBuild.sh
executable file
·49 lines (36 loc) · 1.19 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
#!/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 mkdocs-generator"
echo "-------------------------"
docker run --rm -e VERSION=${VERSION} -e GO111MODULE=on -e HOME=/tmp -u $(id -u ${USER}):$(id -g ${USER}) -v "$PWD":/go/mkdocs-generator -w /go/mkdocs-generator golang:1.15 \
./build.sh
echo ""
echo "---------------------"
echo "Building mkdocs-generator Container version: ${VERSION}"
echo "---------------------"
DTAG="premiereglobal/mkdocs-generator:${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}
fi