-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
56 lines (41 loc) · 1.3 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
SHELL=/bin/bash
# Ensure targets are deleted when an error occurred executing the recipe
.DELETE_ON_ERROR:
# Allows usage of automatic variables in prerequisites
.SECONDEXPANSION:
MAKEFLAGS += --warn-undefined-variables
TARGET=$@
TARGET_MARKER_START = @echo "starting: $(TARGET)"
TARGET_MARKER_END = @echo "ended $(TARGET)"
CI ?=
ifeq ($(CI),travis)
include make/travis.mk
endif
DOCKER_IMAGE_PREFIX := lucasvanlierop/php-extensions
%/.pulled: DOCKER_IMAGE = php:$(subst /,-,$*)
%/.pulled:
$(TARGET_MARKER_START)
docker pull $(DOCKER_IMAGE)
touch $(TARGET)
$(TARGET_MARKER_END)
%/.built: DOCKER_IMAGE = $(DOCKER_IMAGE_PREFIX):$(subst /,-,$*)
%/.built: DOCKER_PHP_BASE_IMAGE_PULLED = $(dir $(@D)).pulled
%/.built: \
$$(DOCKER_PHP_BASE_IMAGE_PULLED) \
$$(shell find $$(@D) -type f -not -name .built -not -name .published)
$(TARGET_MARKER_START)
-docker pull $(DOCKER_IMAGE)
docker build --cache-from $(DOCKER_IMAGE) -t $(DOCKER_IMAGE) $(@D)
touch $(TARGET)
$(TARGET_MARKER_END)
%/.published: DOCKER_IMAGE = $(DOCKER_IMAGE_PREFIX):$(subst /,-,$*)
%/.published: %/.built
$(TARGET_MARKER_START)
docker push $(DOCKER_IMAGE)
touch $(TARGET)
$(TARGET_MARKER_END)
.DEFAULT_GOAL := publish
publish: \
$(shell find . -name Dockerfile | sed 's/Dockerfile/.published/')
$(TARGET_MARKER_START)
$(TARGET_MARKER_END)