forked from brefphp/extra-php-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (93 loc) · 3.63 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
SHELL := /bin/bash
layer ?= *
resolve_php_versions = $(or $(php_versions),`jq -r '.php | join(" ")' ${1}/config.json`)
resolve_tags = `./new-docker-tags.php $(DOCKER_TAG)`
BREF_VERSION = 2
define build_docker_image
docker build -t bref/${1}-php-${2} --build-arg PHP_VERSION=${2} --build-arg BREF_VERSION=${BREF_VERSION} ${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 build --build-arg PHP_VERSION=$${php_version} --build-arg TARGET_IMAGE=$${dir}-php-$${php_version} -t bref/test-$${dir}-$${php_version} tests ; \
docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task bref/test-$${dir}-$${php_version} /opt/bin/php /var/task/test.php ; \
if docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task bref/test-$${dir}-$${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 bref/$${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-extra publish
php ./bref-extra list
# Publish docker images
publish-docker-images: docker-images
for dir in layers/${layer}; do \
for php_version in $(call resolve_php_versions,$${dir}); do \
echo "###############################################"; \
echo "###############################################"; \
echo "### Publishing $${dir} PHP$${php_version}"; \
echo "###"; \
privateImage="bref/$${dir}-php-$${php_version}"; \
publicImage=$${privateImage/layers\//extra-}; \
echo "Image name: $$publicImage"; \
echo ""; \
echo "docker push $$publicImage:latest"; \
docker tag $$privateImage:latest $$publicImage:latest; \
docker push $$publicImage:latest; \
if (test $(DOCKER_TAG)); then \
echo "Pushing tagged images"; \
for tag in $(call resolve_tags); do \
echo ""; \
echo "docker push $$publicImage:$${tag}"; \
docker tag $$privateImage:latest $$publicImage:$${tag}; \
docker push $$publicImage:$${tag}; \
done; \
fi; \
echo ""; \
done \
done