xref: /unit/pkg/docker/Makefile (revision 1783)
1508Sthresh@nginx.com#!/usr/bin/make
2508Sthresh@nginx.com
3953Salexander.borisov@nginx.cominclude ../../version
41410Sthresh@nginx.cominclude ../shasum.mak
5953Salexander.borisov@nginx.com
61764Sdefan@nginx.comDEFAULT_VERSION := $(NXT_VERSION)
7508Sthresh@nginx.com
81764Sdefan@nginx.comVERSION ?= $(DEFAULT_VERSION)
9508Sthresh@nginx.com
101410Sthresh@nginx.comEXPORT_DIR := $(VERSION)
111410Sthresh@nginx.com
12*1783Sthresh@videolan.orgMODULES ?= go jsc node perl php python ruby minimal
13*1783Sthresh@videolan.org
14*1783Sthresh@videolan.orgVERSION_minimal ?=
15*1783Sthresh@videolan.orgCONTAINER_minimal ?= debian:buster-slim
16*1783Sthresh@videolan.orgCONFIGURE_minimal ?=
17*1783Sthresh@videolan.orgINSTALL_minimal ?=	version
18*1783Sthresh@videolan.orgdefine COPY_minimal
19*1783Sthresh@videolan.orgendef
20*1783Sthresh@videolan.org
21*1783Sthresh@videolan.orgVERSION_go ?=		1.15
22*1783Sthresh@videolan.orgCONTAINER_go ?=		golang:$(VERSION_go)
23*1783Sthresh@videolan.orgCONFIGURE_go ?=		go --go-path=$$GOPATH
24*1783Sthresh@videolan.orgINSTALL_go ?=		go-install-src libunit-install
25*1783Sthresh@videolan.orgdefine COPY_go
26*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/lib/x86_64-linux-gnu/libunit.a /usr/lib/x86_64-linux-gnu/\n\$
27*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/include/nxt_* /usr/include/\n\$
28*1783Sthresh@videolan.orgCOPY --from=BUILDER /go/src/ /go/src/
29*1783Sthresh@videolan.orgendef
30*1783Sthresh@videolan.org
31*1783Sthresh@videolan.orgVERSION_jsc ?=		11
32*1783Sthresh@videolan.orgCONTAINER_jsc ?=	openjdk:$(VERSION_jsc)-jdk
33*1783Sthresh@videolan.orgCONFIGURE_jsc ?=	java --jars=/usr/share/unit-jsc-common/
34*1783Sthresh@videolan.orgINSTALL_jsc ?=		java-shared-install java-install
35*1783Sthresh@videolan.orgCOPY_jsc =	 		COPY --from=BUILDER /usr/share/unit-jsc-common/ /usr/share/unit-jsc-common/
36*1783Sthresh@videolan.org
37*1783Sthresh@videolan.orgVERSION_node ?=		15
38*1783Sthresh@videolan.orgCONTAINER_node ?=	node:$(VERSION_node)
39*1783Sthresh@videolan.orgCONFIGURE_node ?=	nodejs --node-gyp=/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
40*1783Sthresh@videolan.orgINSTALL_node ?=		node node-install libunit-install
41*1783Sthresh@videolan.orgdefine COPY_node
42*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/lib/x86_64-linux-gnu/libunit.a /usr/lib/x86_64-linux-gnu/\n\$
43*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/include/nxt_* /usr/include/\n\$
44*1783Sthresh@videolan.orgCOPY --from=BUILDER /usr/local/lib/node_modules/unit-http/ /usr/local/lib/node_modules/unit-http/
45*1783Sthresh@videolan.orgendef
46*1783Sthresh@videolan.org
47*1783Sthresh@videolan.orgVERSION_perl ?=		5.32
48*1783Sthresh@videolan.orgCONTAINER_perl ?=	perl:$(VERSION_perl)
49*1783Sthresh@videolan.orgCONFIGURE_perl ?=	perl
50*1783Sthresh@videolan.orgINSTALL_perl ?=		perl-install
51*1783Sthresh@videolan.orgCOPY_perl =
52*1783Sthresh@videolan.org
53*1783Sthresh@videolan.orgVERSION_php ?=		8.0
54*1783Sthresh@videolan.orgCONTAINER_php ?=	php:$(VERSION_php)-cli
55*1783Sthresh@videolan.orgCONFIGURE_php ?=	php
56*1783Sthresh@videolan.orgINSTALL_php ?=		php-install
57*1783Sthresh@videolan.orgCOPY_php =			RUN ldconfig
58*1783Sthresh@videolan.org
59*1783Sthresh@videolan.orgVERSION_python ?=	3.9
60*1783Sthresh@videolan.orgCONTAINER_python ?=	python:$(VERSION_python)
61*1783Sthresh@videolan.orgCONFIGURE_python ?=	python --config=/usr/local/bin/python3-config
62*1783Sthresh@videolan.orgINSTALL_python ?=	python3-install
63*1783Sthresh@videolan.orgCOPY_python =
64*1783Sthresh@videolan.org
65*1783Sthresh@videolan.orgVERSION_ruby ?=		2.7
66*1783Sthresh@videolan.orgCONTAINER_ruby ?=	ruby:$(VERSION_ruby)
67*1783Sthresh@videolan.orgCONFIGURE_ruby ?=	ruby
68*1783Sthresh@videolan.orgINSTALL_ruby ?=		ruby-install
69*1783Sthresh@videolan.orgCOPY_ruby =			RUN gem install rack
70*1783Sthresh@videolan.org
71508Sthresh@nginx.comdefault:
721410Sthresh@nginx.com	@echo "valid targets: all build dockerfiles push tag export clean"
73508Sthresh@nginx.com
74*1783Sthresh@videolan.orgMODVERSIONS = $(foreach module,$(MODULES),$(module)$(VERSION_$(module)))
75*1783Sthresh@videolan.org
76*1783Sthresh@videolan.orgmodname = $(shell echo $1 | /usr/bin/tr -d '.01234567890-')
77*1783Sthresh@videolan.org
78*1783Sthresh@videolan.orgdockerfiles: $(addprefix Dockerfile., $(MODVERSIONS))
79*1783Sthresh@videolan.orgbuild: $(addprefix build-,$(MODVERSIONS))
80*1783Sthresh@videolan.orgtag: $(addprefix tag-,$(MODVERSIONS))
81*1783Sthresh@videolan.orgpush: $(addprefix push-,$(MODVERSIONS))
82*1783Sthresh@videolan.orgexport: $(addsuffix .tar.gz,$(addprefix $(EXPORT_DIR)/nginx-unit-$(VERSION)-,$(MODVERSIONS))) $(addsuffix .tar.gz.sha512, $(addprefix $(EXPORT_DIR)/nginx-unit-$(VERSION)-,$(MODVERSIONS)))
83508Sthresh@nginx.com
841135Svbart@nginx.comDockerfile.%: ../../version
85508Sthresh@nginx.com	@echo "===> Building $@"
86*1783Sthresh@videolan.org	cat template.Dockerfile | sed \
87*1783Sthresh@videolan.org			-e 's,@@VERSION@@,$(VERSION),g' \
88*1783Sthresh@videolan.org			-e 's,@@CONTAINER@@,$(CONTAINER_$(call modname, $*)),g' \
89*1783Sthresh@videolan.org			-e 's,@@CONFIGURE@@,$(CONFIGURE_$(call modname, $*)),g' \
90*1783Sthresh@videolan.org			-e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \
91*1783Sthresh@videolan.org			-e 's,@@COPY@@,$(COPY_$(call modname, $*)),g' \
92508Sthresh@nginx.com			> $@
93508Sthresh@nginx.com
94508Sthresh@nginx.combuild-%: Dockerfile.%
95*1783Sthresh@videolan.org	docker pull $(CONTAINER_$(call modname, $*))
961638Sthresh@nginx.com	docker build --no-cache -t unit:$(VERSION)-$* -f Dockerfile.$* .
97508Sthresh@nginx.com
981410Sthresh@nginx.comtag-%: build-%
99508Sthresh@nginx.com	docker tag unit:$(VERSION)-$* nginx/unit:$(VERSION)-$*
1001739Sthresh@nginx.com	docker tag unit:$(VERSION)-$* public.ecr.aws/nginx/unit:$(VERSION)-$*
1011410Sthresh@nginx.com
1021410Sthresh@nginx.compush-%: tag-%
103508Sthresh@nginx.com	docker push nginx/unit:$(VERSION)-$*
1041739Sthresh@nginx.com	docker push public.ecr.aws/nginx/unit:$(VERSION)-$*
105508Sthresh@nginx.com
1061410Sthresh@nginx.com$(EXPORT_DIR):
1071410Sthresh@nginx.com	mkdir -p $@
1081410Sthresh@nginx.com
1091410Sthresh@nginx.com$(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz: $(EXPORT_DIR) tag-%
1101410Sthresh@nginx.com	docker save nginx/unit:$(VERSION)-$* | gzip > $@
1111410Sthresh@nginx.com
1121410Sthresh@nginx.com$(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz.sha512: $(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz
1131421Sthresh@nginx.com	$(SHA512SUM) $< | sed 's,$(EXPORT_DIR)/,,' > $@
1141410Sthresh@nginx.com
115*1783Sthresh@videolan.orgall: $(addprefix Dockerfile., $(MODVERSIONS))
116508Sthresh@nginx.com
117508Sthresh@nginx.comclean:
118*1783Sthresh@videolan.org	rm -f $(addprefix Dockerfile., $(MODVERSIONS))
1191410Sthresh@nginx.com	rm -rf $(EXPORT_DIR)
120508Sthresh@nginx.com
121*1783Sthresh@videolan.org.PHONY: default build dockerfiles push tag export clean
122