forked from mantidproject/dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_helpers.sh
executable file
·46 lines (39 loc) · 1.13 KB
/
build_helpers.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
#!/bin/bash
IMAGE="mantidproject/mantid"
function build_image {
DOCKERFILE=$1
EXPECTED_VERSION=$2
TAG=$3
PACKAGE=$4
PATH_ADDITIONS=$5
docker build \
--file=${DOCKERFILE} \
--tag=${IMAGE}:${TAG} \
--build-arg PACKAGE=${PACKAGE} \
--build-arg PATH_ADDITIONS=${PATH_ADDITIONS} \
.
build_result=$?
if [ $build_result -ne 0 ]; then
echo "Build of image for tag \"$TAG\" failed"
exit $build_result
fi
# Try to do a thing in Python for the image that has just been built
version_test=$(docker run --rm mantidproject/mantid:$TAG mantidpython /mantid_version_check.py)
echo "$version_test"
if [ -n "$EXPECTED_VERSION" ]; then
if [ "$EXPECTED_VERSION" == "$version_test" ]; then
echo "Image with tag \"$TAG\" is correct"
else
echo "Image with tag \"$TAG\" failed to build correctly"
exit 1
fi
else
echo "Ignoring expected version test, just looking for something"
if [ -n "$version_test" ]; then
echo "Have \"$version_test\" for version string, close enough"
else
echo "No version string, something is probably broken"
exit 1
fi
fi
}