-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·77 lines (59 loc) · 2.35 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
set -e
pushd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ -z "$DOCKER_PREFIX" ]; then
echo "WARNING: Env var DOCKER_PREFIX not set, assuming haufelexware/wicked."
export DOCKER_PREFIX="haufelexware/wicked."
fi
if [ -z "$DOCKER_TAG" ]; then
echo "WARNING: Env var DOCKER_TAG is not set, assuming 'dev'."
export DOCKER_TAG=dev
fi
noCache=""
if [ ! -z "${DOCKER_NOCACHE}" ]; then
echo "INFO: Building using --no-cache"
noCache="--no-cache"
fi
echo "============================================"
echo "Building normal image..."
echo "============================================"
git log -1 --decorate=short > git_last_commit
git rev-parse --abbrev-ref HEAD > git_branch
export BUILD_ALPINE=""
normalImageName="${DOCKER_PREFIX}kong:${DOCKER_TAG}"
docker build --pull -t ${normalImageName} . ${noCache}
# echo "============================================"
# echo "Building alpine image..."
# echo "============================================"
# export BUILD_ALPINE="-alpine"
# alpineImageName="${DOCKER_PREFIX}portal:${DOCKER_TAG}-alpine"
# docker build --pull -f Dockerfile-alpine -t ${alpineImageName} .
if [ "$1" = "--push" ]; then
echo "============================================"
echo "Logging in to registry..."
echo "============================================"
if [ -z "$DOCKER_REGISTRY_USER" ] || [ -z "$DOCKER_REGISTRY_PASSWORD" ]; then
echo "ERROR: Env vars DOCKER_REGISTRY_USER and/or DOCKER_REGISTRY_PASSWORD not set."
echo "Cannot push images, exiting."
exit 1
fi
if [ -z "$DOCKER_REGISTRY" ]; then
echo "WARNING: Env var DOCKER_REGISTRY not set, assuming official docker hub."
docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASSWORD}
else
docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASSWORD} ${DOCKER_REGISTRY}
fi
echo "============================================"
echo "Pushing ${normalImageName}"
echo "============================================"
docker push ${normalImageName}
# echo "============================================"
# echo "Pushing ${alpineImageName}"
# echo "============================================"
# docker push ${alpineImageName}
else
if [ ! -z "$1" ]; then
echo "WARNING: Unknown parameter '$1'; did you mean --push?"
fi
fi
popd