-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·55 lines (46 loc) · 1.2 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
#!/bin/bash
_filter="$1"
_test="${TEST:-no}"
_push="$PUSH"
set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TESTS_DIR="$DIR/tests"
for d in */ ; do
cd "$DIR/$d"
if [ ! -f Dockerfile ]; then
continue
fi
if [[ ! -z "$_filter" && ! $d =~ $_filter ]]; then
echo "Skipped $d (_filter == $_filter)" >&2
continue
fi
echo "Building $d..."
IS_PHP=0
if [[ $d == php* ]]; then
IS_PHP=1
fi
VERSION="$( head -n 1 "VERSION" )"
TAG="belazor/dbtech-devel:${d%?}"
TAG_WITH_VERSION="$TAG-$VERSION"
docker build \
-t "$TAG" \
-t "$TAG_WITH_VERSION" \
. > build.log
if [ "$IS_PHP" -gt 0 ]; then
if [ "x$_test" = 'xyes' ]; then
echo "Testing..."
eval "IMAGE_TAG_FOR_TESTING=$TAG_WITH_VERSION $TESTS_DIR/run.sh > test.log"
else
echo "Skipped testing (TEST == $_test)" >&2
fi
fi
if [ "x$_push" = 'xyes' ]; then
echo "Pushing..."
( \
docker push "$TAG" && \
docker push "$TAG_WITH_VERSION" \
) > push.log
else
echo 'Skipped pushing, export PUSH=yes before building to do it' >&2
fi
done