-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (63 loc) · 2.41 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
SHELL := /bin/bash
layer ?= *
resolve_php_versions = $(or $(php_versions),`jq -r '.php | join(" ")' ${1}/config.json`)
define build_docker_image
docker build -t php-runtime/${1}-php-${2} --build-arg PHP_VERSION=${2} ${DOCKER_BUILD_FLAGS} ${1}
endef
docker-images:
if [ "${layer}" != "*" ]; then test -d layers/${layer}; fi
set -e; \
for dir in layers/${layer}; do \
for php_version in $(call resolve_php_versions,$${dir}); do \
echo "###############################################"; \
echo "###############################################"; \
echo "### Building $${dir} PHP$${php_version}"; \
echo "###"; \
$(call build_docker_image,$${dir},$${php_version}) ; \
echo ""; \
done \
done
test: docker-images
if [ "${layer}" != "*" ]; then test -d layers/${layer}; fi
set -e; \
for dir in layers/${layer}; do \
for php_version in $(call resolve_php_versions,$${dir}); do \
echo "###############################################"; \
echo "###############################################"; \
echo "### Testing $${dir} PHP$${php_version}"; \
echo "###"; \
docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task php-runtime/$${dir}-php-$${php_version} /opt/bin/php /var/task/test.php ; \
if docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task php-runtime/$${dir}-php-$${php_version} /opt/bin/php -v 2>&1 >/dev/null | grep -q 'Unable\|Warning'; then exit 1; fi ; \
echo ""; \
echo " - Test passed"; \
echo ""; \
done \
done;
# The PHP runtimes
layers: docker-images
if [ "${layer}" != "*" ]; then test -d layers/${layer}; fi
PWD=pwd
rm -rf export/layer-${layer}.zip || true
mkdir -p export/tmp
set -e; \
for dir in layers/${layer}; do \
for php_version in $(call resolve_php_versions,${PWD}/$${dir}); do \
echo "###############################################"; \
echo "###############################################"; \
echo "### Exporting $${dir} PHP$${php_version}"; \
echo "###"; \
cd ${PWD} ; rm -rf export/tmp/${layer} || true ; cd export/tmp ; \
CID=$$(docker create --entrypoint=scratch php-runtime/$${dir}-php-$${php_version}) ; \
docker cp $${CID}:/opt . ; \
docker rm $${CID} ; \
cd ./opt ; \
zip --quiet -X --recurse-paths ../../`echo "$${dir}-php-$${php_version}" | sed -e "s/layers\//layer-/g"`.zip . ; \
echo ""; \
done \
done
rm -rf export/tmp
clean:
rm -f export/layer-*
publish: layers
php ./bref-layer publish
php ./bref-layer list