-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·37 lines (27 loc) · 934 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
#!/bin/bash
set -e
declare -r PV_DOCKER_REGISTRY="polyverse"
declare -r PV_NAME="tcp-echo-server"
declare -r PV_TARGETS="alpine centos trusty xenial bionic"
main() {
for PV_TARGET in ${PV_TARGETS}; do
build ${PV_TARGET}
[ $? -ne 0 ] && return 1
done
return 0
}
build() {
declare -r PV_TARGET="${1}"
# Build the image
docker build -f Dockerfile.${PV_TARGET} -t "${PV_NAME}.${PV_TARGET}" -t "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:latest" .
[ $? -ne 0 ] && return 1
# Don't tag when there are uncommitted changes.
if [ -z "$(git status -s -uno)" ]; then
declare -r PV_GIT_COMMIT="$(git rev-parse --verify HEAD)"
docker tag "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:latest" "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:${PV_GIT_COMMIT}"
[ $? -ne 0 ] && return 1
fi
return 0
}
main "$@"
exit $?