-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·52 lines (46 loc) · 1.38 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
#!/bin/bash
ENV_VERSION_TAG=""
if [[ -e ./src/common/common-bash.sh ]]; then
source ./src/common/common-bash.sh .
fi
source ./properties.sh .
echo ""
amnt "--------------------------------------------------------"
amnt "Building new Docker image(${maintainer}/${imagename})"
docker build --rm -t $maintainer/$imagename .
last_status=$?
if [[ "${last_status}" == "0" ]]; then
echo ""
if [[ "${ENV_VERSION_TAG}" != "" ]]; then
image_csum=$(docker images | grep "${maintainer}/${imagename} " | grep latest | awk '{print $3}')
if [[ "${image_csum}" != "" ]]; then
docker tag $image_csum $maintainer/$imagename:$ENV_VERSION_TAG
last_status=$?
if [[ "${last_status}" != "0" ]]; then
err "Failed to tag image(${imagename}) with Tag(${ENV_VERSION_TAG})"
lg ""
exit 1
else
good "Build Successful Tagged Image(${imagename}) with Tag(${ENV_VERSION_TAG})"
fi
echo ""
exit 0
else
lg ""
err "Build failed to find latest image(${imagename}) with Tag(${ENV_VERSION_TAG})"
echo ""
exit 1
fi
else
good "Build Successful"
echo ""
exit 0
fi
lg ""
else
lg ""
err "Build failed with exit code: ${last_status}"
echo ""
exit 1
fi
exit 0