xref: /unit/pkg/docker/Makefile (revision 600:694767e0b8c9)
1#!/usr/bin/make
2
3DEFAULT_VERSION := $(shell grep 'define NXT_VERSION' ../../src/nxt_main.h \
4			| sed -e 's/^.*"\(.*\)".*/\1/')
5DEFAULT_RELEASE := 1
6
7VERSION ?= $(DEFAULT_VERSION)
8RELEASE ?= $(DEFAULT_RELEASE)
9CODENAME := stretch
10
11UNIT_VERSION = $(VERSION)-$(RELEASE)~$(CODENAME)
12
13MODULES = python2.7 python3.5 php7.0 go1.7-dev go1.8-dev perl5.24 ruby2.3 \
14          full minimal
15
16MODULE_php7.0="unit=$${UNIT_VERSION} unit-php=$${UNIT_VERSION}"
17
18MODULE_python2.7="unit=$${UNIT_VERSION} unit-python2.7=$${UNIT_VERSION}"
19
20MODULE_python3.5="unit=$${UNIT_VERSION} unit-python3.5=$${UNIT_VERSION}"
21
22MODULE_go1.7-dev="unit=$${UNIT_VERSION} unit-go1.7=$${UNIT_VERSION} gcc"
23
24MODULE_go1.8-dev="unit=$${UNIT_VERSION} unit-go1.8=$${UNIT_VERSION} gcc"
25
26MODULE_perl5.24="unit=$${UNIT_VERSION} unit-perl=$${UNIT_VERSION}"
27
28MODULE_ruby2.3="unit=$${UNIT_VERSION} unit-ruby=$${UNIT_VERSION}"
29
30MODULE_full="unit=$${UNIT_VERSION} unit-php=$${UNIT_VERSION} unit-python2.7=$${UNIT_VERSION} unit-python3.5=$${UNIT_VERSION} unit-perl=$${UNIT_VERSION} unit-ruby=$${UNIT_VERSION}"
31
32MODULE_minimal="unit=$${UNIT_VERSION}"
33
34export \
35		MODULE_python2.7 \
36 		MODULE_python3.5 \
37 		MODULE_php7.0 \
38 		MODULE_go1.7-dev \
39 		MODULE_go1.8-dev \
40 		MODULE_perl5.24 \
41 		MODULE_ruby2.3 \
42		MODULE_full \
43 		MODULE_minimal
44
45default:
46	@echo "valid targets: all build dockerfiles push clean"
47
48dockerfiles: $(addprefix Dockerfile., $(MODULES))
49build: dockerfiles $(addprefix build-,$(MODULES))
50push: build $(addprefix push-,$(MODULES)) latest
51
52Dockerfile.%: ../../src/nxt_main.h
53	@echo "===> Building $@"
54	cat Dockerfile.tmpl | sed \
55			-e 's,@@UNITPACKAGES@@,$(MODULE_$*),g' \
56			-e 's,@@UNIT_VERSION@@,$(UNIT_VERSION),g' \
57			> $@
58
59build-%: Dockerfile.%
60	docker build -t unit:$(VERSION)-$* -f Dockerfile.$* .
61
62push-%:
63	docker tag unit:$(VERSION)-$* nginx/unit:$(VERSION)-$*
64	docker push nginx/unit:$(VERSION)-$*
65
66latest:
67	docker tag nginx/unit:$(VERSION)-full nginx/unit:latest
68	docker push nginx/unit:latest
69
70all: $(addprefix Dockerfile., $(MODULES))
71
72clean:
73	rm -f $(addprefix Dockerfile., $(MODULES))
74
75.PHONY: default all build dockerfiles latest push clean
76