xref: /unit/pkg/docker/Makefile (revision 2091:1b18733cb113)
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
121783Sthresh@videolan.orgMODULES ?= go jsc node perl php python ruby minimal
131783Sthresh@videolan.org
141783Sthresh@videolan.orgVERSION_minimal ?=
151957Sthresh@nginx.comCONTAINER_minimal ?= debian:bullseye-slim
161783Sthresh@videolan.orgCONFIGURE_minimal ?=
171783Sthresh@videolan.orgINSTALL_minimal ?=	version
181783Sthresh@videolan.orgdefine COPY_minimal
191783Sthresh@videolan.orgendef
201783Sthresh@videolan.org
21*2091Sthresh@nginx.comVERSION_go ?=		1.18
221783Sthresh@videolan.orgCONTAINER_go ?=		golang:$(VERSION_go)
231783Sthresh@videolan.orgCONFIGURE_go ?=		go --go-path=$$GOPATH
241783Sthresh@videolan.orgINSTALL_go ?=		go-install-src libunit-install
251783Sthresh@videolan.orgdefine COPY_go
262056Sthresh@nginx.comCOPY --from=BUILDER /usr/lib/\*-linux-gnu/libunit.a /tmp/\n\$
271783Sthresh@videolan.orgCOPY --from=BUILDER /usr/include/nxt_* /usr/include/\n\$
281783Sthresh@videolan.orgCOPY --from=BUILDER /go/src/ /go/src/
291783Sthresh@videolan.orgendef
301783Sthresh@videolan.org
311783Sthresh@videolan.orgVERSION_jsc ?=		11
321783Sthresh@videolan.orgCONTAINER_jsc ?=	openjdk:$(VERSION_jsc)-jdk
331783Sthresh@videolan.orgCONFIGURE_jsc ?=	java --jars=/usr/share/unit-jsc-common/
341783Sthresh@videolan.orgINSTALL_jsc ?=		java-shared-install java-install
351783Sthresh@videolan.orgCOPY_jsc =	 		COPY --from=BUILDER /usr/share/unit-jsc-common/ /usr/share/unit-jsc-common/
361783Sthresh@videolan.org
371957Sthresh@nginx.comVERSION_node ?=		16
381783Sthresh@videolan.orgCONTAINER_node ?=	node:$(VERSION_node)
391783Sthresh@videolan.orgCONFIGURE_node ?=	nodejs --node-gyp=/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
401783Sthresh@videolan.orgINSTALL_node ?=		node node-install libunit-install
411783Sthresh@videolan.orgdefine COPY_node
422056Sthresh@nginx.comCOPY --from=BUILDER /usr/lib/\*-linux-gnu/libunit.a /tmp/\n\$
431783Sthresh@videolan.orgCOPY --from=BUILDER /usr/include/nxt_* /usr/include/\n\$
441783Sthresh@videolan.orgCOPY --from=BUILDER /usr/local/lib/node_modules/unit-http/ /usr/local/lib/node_modules/unit-http/
451783Sthresh@videolan.orgendef
461783Sthresh@videolan.org
471957Sthresh@nginx.comVERSION_perl ?=		5.34
481783Sthresh@videolan.orgCONTAINER_perl ?=	perl:$(VERSION_perl)
491783Sthresh@videolan.orgCONFIGURE_perl ?=	perl
501783Sthresh@videolan.orgINSTALL_perl ?=		perl-install
511783Sthresh@videolan.orgCOPY_perl =
521783Sthresh@videolan.org
532057Sthresh@nginx.comVERSION_php ?=		8.1
541783Sthresh@videolan.orgCONTAINER_php ?=	php:$(VERSION_php)-cli
551783Sthresh@videolan.orgCONFIGURE_php ?=	php
561783Sthresh@videolan.orgINSTALL_php ?=		php-install
571783Sthresh@videolan.orgCOPY_php =			RUN ldconfig
581783Sthresh@videolan.org
592063Sthresh@nginx.comVERSION_python ?=	3.10
601783Sthresh@videolan.orgCONTAINER_python ?=	python:$(VERSION_python)
611783Sthresh@videolan.orgCONFIGURE_python ?=	python --config=/usr/local/bin/python3-config
621783Sthresh@videolan.orgINSTALL_python ?=	python3-install
631783Sthresh@videolan.orgCOPY_python =
641783Sthresh@videolan.org
65*2091Sthresh@nginx.comVERSION_ruby ?=		3.1
661783Sthresh@videolan.orgCONTAINER_ruby ?=	ruby:$(VERSION_ruby)
671783Sthresh@videolan.orgCONFIGURE_ruby ?=	ruby
681783Sthresh@videolan.orgINSTALL_ruby ?=		ruby-install
691783Sthresh@videolan.orgCOPY_ruby =			RUN gem install rack
701783Sthresh@videolan.org
71508Sthresh@nginx.comdefault:
721410Sthresh@nginx.com	@echo "valid targets: all build dockerfiles push tag export clean"
73508Sthresh@nginx.com
741783Sthresh@videolan.orgMODVERSIONS = $(foreach module,$(MODULES),$(module)$(VERSION_$(module)))
751783Sthresh@videolan.org
761783Sthresh@videolan.orgmodname = $(shell echo $1 | /usr/bin/tr -d '.01234567890-')
771783Sthresh@videolan.org
781783Sthresh@videolan.orgdockerfiles: $(addprefix Dockerfile., $(MODVERSIONS))
791783Sthresh@videolan.orgbuild: $(addprefix build-,$(MODVERSIONS))
801783Sthresh@videolan.orgtag: $(addprefix tag-,$(MODVERSIONS))
811783Sthresh@videolan.orgpush: $(addprefix push-,$(MODVERSIONS))
821783Sthresh@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 $@"
861783Sthresh@videolan.org	cat template.Dockerfile | sed \
871783Sthresh@videolan.org			-e 's,@@VERSION@@,$(VERSION),g' \
881783Sthresh@videolan.org			-e 's,@@CONTAINER@@,$(CONTAINER_$(call modname, $*)),g' \
891783Sthresh@videolan.org			-e 's,@@CONFIGURE@@,$(CONFIGURE_$(call modname, $*)),g' \
901783Sthresh@videolan.org			-e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \
911783Sthresh@videolan.org			-e 's,@@COPY@@,$(COPY_$(call modname, $*)),g' \
92508Sthresh@nginx.com			> $@
93508Sthresh@nginx.com
94508Sthresh@nginx.combuild-%: Dockerfile.%
951783Sthresh@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)-$*
1001410Sthresh@nginx.com
1011410Sthresh@nginx.compush-%: tag-%
102508Sthresh@nginx.com	docker push nginx/unit:$(VERSION)-$*
103508Sthresh@nginx.com
1041410Sthresh@nginx.com$(EXPORT_DIR):
1051410Sthresh@nginx.com	mkdir -p $@
1061410Sthresh@nginx.com
1071410Sthresh@nginx.com$(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz: $(EXPORT_DIR) tag-%
1081410Sthresh@nginx.com	docker save nginx/unit:$(VERSION)-$* | gzip > $@
1091410Sthresh@nginx.com
1101410Sthresh@nginx.com$(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz.sha512: $(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz
1111421Sthresh@nginx.com	$(SHA512SUM) $< | sed 's,$(EXPORT_DIR)/,,' > $@
1121410Sthresh@nginx.com
1131783Sthresh@videolan.orgall: $(addprefix Dockerfile., $(MODVERSIONS))
114508Sthresh@nginx.com
115508Sthresh@nginx.comclean:
1161783Sthresh@videolan.org	rm -f $(addprefix Dockerfile., $(MODVERSIONS))
1171410Sthresh@nginx.com	rm -rf $(EXPORT_DIR)
118508Sthresh@nginx.com
1191783Sthresh@videolan.org.PHONY: default build dockerfiles push tag export clean
120