-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
executable file
·69 lines (58 loc) · 1.63 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
#!/bin/sh
_filter="$1"
_test="${TEST:-yes}"
_push="$PUSH"
set -e
DIR=$( pwd )
TESTS_DIR="$DIR/tests"
EXT_INSTALL="exif gd gmp mysqli opcache pcntl soap sockets zip"
PECL_INSTALL="apcu igbinary imagick memcached redis xdebug"
for d in */ ; do
cd "$DIR/$d"
if [ ! -f Dockerfile ]; then
continue
fi
if [ ! -z "$_filter" -a "x$d" != "x$_filter" ]; then
echo "Skipped $d (_filter == $_filter)" >&2
continue
fi
echo "Building $d..."
IS_PHP=0
case $d in
php-* ) IS_PHP=1
esac
VERSION="$( head -n 1 "VERSION" )"
TAG="xfrocks/xenforo:${d%?}"
if [ "x$CIRCLE_BRANCH" != 'xmaster' ]; then
TAG="$TAG-$CIRCLE_BRANCH"
fi
TAG_WITH_VERSION="$TAG-$VERSION"
docker build \
--build-arg DOCKER_XENFORO_PHP_EXT_INSTALL="$EXT_INSTALL" \
--build-arg DOCKER_XENFORO_PHP_PECL_INSTALL="$PECL_INSTALL" \
-t "$TAG" \
-t "$TAG_WITH_VERSION" \
. > build.log
if [ "$IS_PHP" -gt 0 ]; then
if [ "x$_test" = 'xyes' ]; then
printf "Testing... "
if (export IMAGE_TAG_FOR_TESTING=$TAG_WITH_VERSION && cd $TESTS_DIR && ./run.sh) >test.log; then
echo "OK"
else
echo "failed"
exit 1
fi
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