-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·38 lines (31 loc) · 1016 Bytes
/
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
34
35
36
37
38
#!/usr/bin/env bash
set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
cd -P "$( dirname "$SOURCE" )"
pwd
}
cd "$(get_script_dir)"
if [[ "$NO_SUDO" || -n "$CIRCLECI" ]]; then
DOCKER="docker"
elif groups "$USER" | grep &>/dev/null '\bdocker\b'; then
DOCKER="docker"
else
DOCKER="sudo docker"
fi
source ./.dockerimage
VCS_REF=$(git describe --tags --dirty)
VERSION=$(git describe --tags --dirty)
docker build --build-arg BUILD_DATE=$(date -Iseconds) \
--build-arg VCS_REF=$VCS_REF \
--build-arg VERSION=$VERSION \
--tag "$IMAGE:latest" \
--tag "$IMAGE:$VERSION" \
.