-
Notifications
You must be signed in to change notification settings - Fork 112
/
Makefile
81 lines (76 loc) · 2.16 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
71
72
73
74
75
76
77
78
79
80
81
SHELL := /bin/bash
ALL: build
.PHONY: build test push
PARENT_IMAGE := php
IMAGE := chialab/php
VERSION ?= latest
PHP_VERSION = $(firstword $(subst -, ,$(VERSION)))
# Extensions.
EXTENSIONS := \
amqp \
bcmath \
bz2 \
calendar \
event \
exif \
gd \
gettext \
iconv \
imagick \
intl \
ldap \
mbstring \
memcached \
mysqli \
OPcache \
pdo_mysql \
pdo_pgsql \
pgsql \
redis \
soap \
xsl \
zip \
sockets
ifeq (,$(findstring $(PHP_VERSION), 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 latest alpine))
# Add more extensions to PHP < 7.2.
EXTENSIONS += mcrypt
endif
ifeq (,$(findstring $(PHP_VERSION), 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 latest alpine))
# Add more extensions to 5.x series images.
EXTENSIONS += mysql
endif
build:
@echo " =====> Building $(REGISTRY)$(IMAGE):$(VERSION)..."
docker image build --quiet --build-arg 'BASE_IMAGE=$(PARENT_IMAGE):$(VERSION)' -t $(REGISTRY)$(IMAGE):$(VERSION) .
test:
@echo -e "=====> Testing loaded extensions... \c"
@if [[ -z `docker image ls $(REGISTRY)$(IMAGE) | grep "\s$(VERSION)\s"` ]]; then \
echo 'FAIL [Missing image!!!]'; \
exit 1; \
fi
@IMAGE_PHP_VERSION=`docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) sh -c '/bin/echo $$PHP_VERSION' | cut -d '.' -f 1,2`; \
if [[ "$(PHP_VERSION)" != "latest" && "$(PHP_VERSION)" != "alpine" && "$${IMAGE_PHP_VERSION}" != "$(PHP_VERSION)" ]]; then \
echo "FAIL [wrong PHP version: expected $(PHP_VERSION), got $${IMAGE_PHP_VERSION}]"; \
exit 1; \
fi
@modules=`docker container run --rm $(REGISTRY)$(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 container run --rm $(REGISTRY)$(IMAGE):$(VERSION) apache2ctl -M 2> /dev/null`; \
if [[ "$${apache}" != *'rewrite_module'* ]]; then \
echo 'FAIL [mod_rewrite]'; \
exit 1; \
fi \
fi
@if [[ -z `docker container run --rm $(REGISTRY)$(IMAGE):$(VERSION) composer --version 2> /dev/null | grep '^Composer version 2\.[0-9][0-9]*'` ]]; then \
echo 'FAIL [Composer]'; \
exit 1; \
fi
@echo 'OK'
push:
docker image push $(REGISTRY)$(IMAGE):$(VERSION)