-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
70 lines (66 loc) · 1.61 KB
/
Makefile
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
SHELL := /bin/bash
.PHONY: pull build-nopull build test
PARENT_IMAGE := chialab/php
IMAGE := lamasbr/docker-php
VERSION ?= latest
PHP_VERSION = $(firstword $(subst -, ,$(VERSION)))
# Extensions.
EXTENSIONS := \
bcmath \
bz2 \
calendar \
exif \
iconv \
intl \
gd \
ldap \
mbstring \
memcached \
mysqli \
OPcache \
pdo_mysql \
pdo_pgsql \
pgsql \
redis \
soap \
zip
ifeq (,$(findstring $(PHP_VERSION), 7.3 latest))
# Add more extensions to PHP < 7.2.
EXTENSIONS += mcrypt
endif
ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 latest))
# Add more extensions to 5.x series images.
EXTENSIONS += mysql
endif
build:
@echo " =====> Building $(IMAGE):$(VERSION)..."
@dir="$(subst -,/,$(VERSION))"; \
if [[ "$(VERSION)" == 'latest' ]]; then \
dir='.'; \
fi; \
docker build --quiet -t $(IMAGE):$(VERSION) $${dir}
test:
@echo -e "=====> Testing loaded extensions... \c"
@if [[ -z `docker images $(IMAGE) | grep "\s$(VERSION)\s"` ]]; then \
echo 'FAIL [Missing image!!!]'; \
exit 1; \
fi
@modules=`docker run --rm $(IMAGE):$(VERSION) php -m`; \
for ext in $(EXTENSIONS); do \
if [[ "$${modules}" != *"$${ext}"* ]]; then \
echo "FAIL [$${ext}]"; \
exit 1; \
fi \
done
@if [[ "$(VERSION)" == *'-apache' ]]; then \
apache=`docker run --rm $(IMAGE):$(VERSION) apache2ctl -M 2> /dev/null`; \
if [[ "$${apache}" != *'rewrite_module'* ]]; then \
echo 'FAIL [mod_rewrite]'; \
exit 1; \
fi \
fi
@if [[ -z `docker run --rm $(IMAGE):$(VERSION) composer --version 2> /dev/null | grep '^Composer version [0-9][0-9]*\.[0-9][0-9]*'` ]]; then \
echo 'FAIL [Composer]'; \
exit 1; \
fi
@echo 'OK'