forked from redhat-developer/s2i-dotnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·71 lines (64 loc) · 1.84 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
#!/bin/bash
#
# Build Docker images and run tests.
#
# PRE: Docker daemon running, s2i binary available.
#
# Supported environment variables:
#
# -----------------------------------------------------
# TEST_OPENSHIFT If 'true' run tests to make sure
# released images work against the
# test application used in OpenShift
#
# VERSIONS The list of versions to build/test.
# Defaults to all versions. i.e "1.0 1.1".
# -----------------------------------------------------
#
# Usage:
# $ sudo ./build.sh
# $ sudo VERSIONS=1.0 ./build.sh
#
version_no_dot() {
local version=$1
echo ${version} | sed 's/\.//g'
}
image_exists() {
docker inspect $1 &>/dev/null
}
check_result_msg() {
local retval=$1
local msg=$2
if [ ${retval} -ne 0 ]; then
echo 1>&2 "${msg}"
exit 1
fi
}
VERSIONS="${VERSIONS:-1.0 1.1}"
for v in ${VERSIONS}; do
v_no_dot="$( version_no_dot ${v} )"
img_name="dotnet/dotnetcore-${v_no_dot}-rhel7"
pushd ${v} &>/dev/null
if ! image_exists ${img_name}; then
echo "Building Docker image ${img_name} ..."
docker build -f Dockerfile.rhel7 -t ${img_name} .
check_result_msg $? "Building Docker image ${img_name} FAILED!"
fi
echo "Running tests on image ${img_name} ..."
./test/run
check_result_msg $? "Tests for image ${img_name} FAILED!"
popd &>/dev/null
done
if [ "$TEST_OPENSHIFT" = "true" ]; then
for v in ${VERSIONS}; do
v_no_dot="$( version_no_dot ${v} )"
img_name="registry.access.redhat.com/dotnet/dotnetcore-${v_no_dot}-rhel7:latest"
pushd ${v} &>/dev/null
echo "Running tests on image ${img_name} ..."
IMAGE_NAME="${img_name}" OPENSHIFT_ONLY=true ./test/run
check_result_msg $? "Tests for image ${img_name} FAILED!"
popd &>/dev/null
done
fi
echo "ALL builds and tests were successful!"
exit 0