forked from srsolutionsag/docker-ilias-base
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
52 lines (44 loc) · 1.15 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
IMAGE_NAME ?= minervis/ilias-base
IMAGES = \
6/php7.2-apache \
6/php7.3-apache \
6/php7.4-apache \
7/php7.3-apache \
7/php7.4-apache \
8/php7.4-apache \
8/php8.0-apache \
9-alpha/php8.1-apache \
9-alpha/php8.2-apache
LATEST = 7/php7.4-apache
variant = $$(basename $1)
branch = $$(basename $$(dirname $1))
tag = $$(echo $1 | sed 's|/|-|')
php = $$(echo $1 | sed -E 's|.*php(.*)|\1|')
.ONESHELL:
all: $(IMAGES) tag
.PHONY: $(IMAGES)
$(IMAGES):
@variant=$(call variant,$@)
@branch=$(call branch,$@)
@php=$(call php,$$variant)
@echo "Building $(IMAGE_NAME):$$branch-$$variant"
docker build --rm --pull \
-f $$branch/Dockerfile \
--build-arg PHP_VERSION=$$php \
-t $(IMAGE_NAME):$$branch-$$variant \
.
.PHONY: tag
tag: $(LATEST)
@for i in $(IMAGES); do \
variant=$(call variant,$$i);
branch=$(call branch,$$i);
tag=$(call tag,$$i);
echo "Tagging $(IMAGE_NAME):$$tag as $(IMAGE_NAME):$$branch"; \
docker tag $(IMAGE_NAME):$$tag $(IMAGE_NAME):$$branch; \
done
@latest=$(IMAGE_NAME):$(call tag,$(LATEST))
@echo "Tagging $$latest as latest"
docker tag $$latest $(IMAGE_NAME):latest
.PHONY: push
push:
docker push -a $(IMAGE_NAME)