xref: /unit/pkg/docker/Makefile (revision 2765:5e31d3ff500a)
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)
92408Sthresh@nginx.comPATCHLEVEL ?= 1
10508Sthresh@nginx.com
112532Sthresh@nginx.comMODULES ?= go jsc node perl php python ruby wasm
121783Sthresh@videolan.org
132410Sthresh@nginx.comVARIANT ?= bullseye
142410Sthresh@nginx.com
152453Sthresh@nginx.comVERSIONS_minimal ?=
162410Sthresh@nginx.comCONTAINER_minimal ?= debian:$(VARIANT)-slim
171783Sthresh@videolan.orgCONFIGURE_minimal ?=
181783Sthresh@videolan.orgINSTALL_minimal ?=	version
192385Sthresh@nginx.comRUN_minimal ?=		/bin/true
202530Sthresh@nginx.comMODULE_PREBUILD_minimal ?= /bin/true
211783Sthresh@videolan.org
222665Sd.callahan@f5.comVERSIONS_go ?=		1.21 1.22
232410Sthresh@nginx.comVARIANT_go ?=		$(VARIANT)
242453Sthresh@nginx.com$(foreach goversion, $(VERSIONS_go), $(eval CONTAINER_go$(goversion) = golang:$(goversion)-$(VARIANT_go)))
251783Sthresh@videolan.orgCONFIGURE_go ?=		go --go-path=$$GOPATH
261783Sthresh@videolan.orgINSTALL_go ?=		go-install-src libunit-install
272385Sthresh@nginx.comRUN_go ?=			/bin/true
282530Sthresh@nginx.comMODULE_PREBUILD_go ?= /bin/true
291783Sthresh@videolan.org
302453Sthresh@nginx.comVERSIONS_jsc ?=		11
312410Sthresh@nginx.comVARIANT_jsc ?=		jammy
322453Sthresh@nginx.com$(foreach jscversion, $(VERSIONS_jsc), $(eval CONTAINER_jsc$(jscversion) = eclipse-temurin:$(jscversion)-jdk-$(VARIANT_jsc)))
331783Sthresh@videolan.orgCONFIGURE_jsc ?=	java --jars=/usr/share/unit-jsc-common/
341783Sthresh@videolan.orgINSTALL_jsc ?=		java-shared-install java-install
352540Sthresh@nginx.comRUN_jsc ?=	 		rm -rf /root/.m2
362530Sthresh@nginx.comMODULE_PREBUILD_jsc ?= /bin/true
371783Sthresh@videolan.org
382665Sd.callahan@f5.comVERSIONS_node ?=	20 21
392410Sthresh@nginx.comVARIANT_node ?=		$(VARIANT)
402453Sthresh@nginx.com$(foreach nodeversion, $(VERSIONS_node), $(eval CONTAINER_node$(nodeversion) = node:$(nodeversion)-$(VARIANT_node)))
412530Sthresh@nginx.comCONFIGURE_node ?=	nodejs --node-gyp=/usr/local/bin/node-gyp
421783Sthresh@videolan.orgINSTALL_node ?=		node node-install libunit-install
432539Sthresh@nginx.comRUN_node ?=			rm -rf /root/.cache/ \&\& rm -rf /root/.npm
442530Sthresh@nginx.comMODULE_PREBUILD_node ?=	npm -g install node-gyp
451783Sthresh@videolan.org
462534Sthresh@nginx.comVERSIONS_perl ?=	5.36 5.38
472410Sthresh@nginx.comVARIANT_perl ?=		$(VARIANT)
482453Sthresh@nginx.com$(foreach perlversion, $(VERSIONS_perl), $(eval CONTAINER_perl$(perlversion) = perl:$(perlversion)-$(VARIANT_perl)))
491783Sthresh@videolan.orgCONFIGURE_perl ?=	perl
501783Sthresh@videolan.orgINSTALL_perl ?=		perl-install
512385Sthresh@nginx.comRUN_perl ?=			/bin/true
522530Sthresh@nginx.comMODULE_PREBUILD_perl ?=	/bin/true
531783Sthresh@videolan.org
542665Sd.callahan@f5.comVERSIONS_php ?=		8.2 8.3
552410Sthresh@nginx.comVARIANT_php ?=		cli-$(VARIANT)
562453Sthresh@nginx.com$(foreach phpversion, $(VERSIONS_php), $(eval CONTAINER_php$(phpversion) = php:$(phpversion)-$(VARIANT_php)))
571783Sthresh@videolan.orgCONFIGURE_php ?=	php
581783Sthresh@videolan.orgINSTALL_php ?=		php-install
592385Sthresh@nginx.comRUN_php ?=			ldconfig
602530Sthresh@nginx.comMODULE_PREBUILD_php ?= /bin/true
611783Sthresh@videolan.org
622640Stomclesius@gmail.comVERSIONS_python ?=  3.11 3.12
632410Sthresh@nginx.comVARIANT_python ?=	$(VARIANT)
642453Sthresh@nginx.com$(foreach pythonversion, $(VERSIONS_python), $(eval CONTAINER_python$(pythonversion) = python:$(pythonversion)-$(VARIANT_python)))
651783Sthresh@videolan.orgCONFIGURE_python ?=	python --config=/usr/local/bin/python3-config
661783Sthresh@videolan.orgINSTALL_python ?=	python3-install
672385Sthresh@nginx.comRUN_python ?=		/bin/true
682530Sthresh@nginx.comMODULE_PREBUILD_python ?= /bin/true
691783Sthresh@videolan.org
702665Sd.callahan@f5.comVERSIONS_ruby ?=	3.2 3.3
712410Sthresh@nginx.comVARIANT_ruby ?=		$(VARIANT)
722453Sthresh@nginx.com$(foreach rubyversion, $(VERSIONS_ruby), $(eval CONTAINER_ruby$(rubyversion) = ruby:$(rubyversion)-$(VARIANT_ruby)))
731783Sthresh@videolan.orgCONFIGURE_ruby ?=	ruby
741783Sthresh@videolan.orgINSTALL_ruby ?=		ruby-install
752541Sthresh@nginx.comRUN_ruby ?=			gem install rack \&\& rm -rf /root/.local
762530Sthresh@nginx.comMODULE_PREBUILD_ruby ?=	/bin/true
771783Sthresh@videolan.org
782532Sthresh@nginx.comVERSIONS_wasm ?=
792532Sthresh@nginx.comCONTAINER_wasm ?= debian:$(VARIANT)-slim
80*2690Sa.clayton@nginx.comCONFIGURE_wasm ?= wasm --include-path=\`pwd\`/pkg/contrib/wasmtime/crates/c-api/include --lib-path=/usr/lib/\$$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ \&\& ./configure wasm-wasi-component
81*2690Sa.clayton@nginx.comINSTALL_wasm ?=   wasm-install wasm-wasi-component-install
82*2690Sa.clayton@nginx.comRUN_wasm ?=       /bin/true
83*2690Sa.clayton@nginx.com
842532Sthresh@nginx.comdefine MODULE_PREBUILD_wasm
852689Sa.clayton@nginx.comapt-get install --no-install-recommends --no-install-suggests -y libclang-dev \\\n \
862689Sa.clayton@nginx.com\ \ \ \&\& export RUST_VERSION=1.76.0 \\\n \
872532Sthresh@nginx.com\ \ \ \&\& export RUSTUP_HOME=/usr/src/unit/rustup \\\n \
882532Sthresh@nginx.com\ \ \ \&\& export CARGO_HOME=/usr/src/unit/cargo \\\n    \
892532Sthresh@nginx.com\ \ \ \&\& export PATH=/usr/src/unit/cargo/bin:\$$PATH \\\n \
902532Sthresh@nginx.com\ \ \ \&\& dpkgArch="\$$\(dpkg --print-architecture\)" \\\n \
912532Sthresh@nginx.com\ \ \ \&\& case "\$${dpkgArch##*-}" in \\\n \
922532Sthresh@nginx.com\ \ \ \ \ \ amd64\) rustArch="x86_64-unknown-linux-gnu"; rustupSha256="0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db" ;; \\\n \
932532Sthresh@nginx.com\ \ \ \ \ \ arm64\) rustArch="aarch64-unknown-linux-gnu"; rustupSha256="673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800" ;; \\\n \
942532Sthresh@nginx.com\ \ \ \ \ \ *\) echo \>\&2 "unsupported architecture: \$${dpkgArch}"; exit 1 ;; \\\n \
952532Sthresh@nginx.com\ \ \ \esac \\\n \
962532Sthresh@nginx.com\ \ \ \&\& url="https://static.rust-lang.org/rustup/archive/1.26.0/\$${rustArch}/rustup-init" \\\n \
972532Sthresh@nginx.com\ \ \ \&\& curl -L -O "\$$url" \\\n \
982532Sthresh@nginx.com\ \ \ \&\& echo "\$${rustupSha256} *rustup-init" | sha256sum -c - \\\n \
992532Sthresh@nginx.com\ \ \ \&\& chmod +x rustup-init \\\n \
1002532Sthresh@nginx.com\ \ \ \&\& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain \$$RUST_VERSION --default-host \$${rustArch} \\\n \
1012532Sthresh@nginx.com\ \ \ \&\& rm rustup-init \\\n \
1022532Sthresh@nginx.com\ \ \ \&\& rustup --version \\\n \
1032532Sthresh@nginx.com\ \ \ \&\& cargo --version \\\n \
1042532Sthresh@nginx.com\ \ \ \&\& rustc --version \\\n \
1052532Sthresh@nginx.com\ \ \ \&\& make -C pkg/contrib .wasmtime \\\n \
1062532Sthresh@nginx.com\ \ \ \&\& install -pm 755 pkg/contrib/wasmtime/target/release/libwasmtime.so /usr/lib/\$$\(dpkg-architecture -q DEB_HOST_MULTIARCH\)/
1072532Sthresh@nginx.comendef
1082532Sthresh@nginx.com
109508Sthresh@nginx.comdefault:
1102454Sthresh@nginx.com	@echo "valid targets: all build dockerfiles library clean"
111508Sthresh@nginx.com
1122532Sthresh@nginx.comMODVERSIONS = $(foreach module, $(MODULES), $(foreach modversion, $(shell for v in $(VERSIONS_$(module)); do echo $$v; done | sort -r), $(module)$(modversion))) wasm minimal
1131783Sthresh@videolan.org
1141783Sthresh@videolan.orgmodname = $(shell echo $1 | /usr/bin/tr -d '.01234567890-')
1151783Sthresh@videolan.org
1161783Sthresh@videolan.orgdockerfiles: $(addprefix Dockerfile., $(MODVERSIONS))
1172453Sthresh@nginx.combuild: $(addprefix build-, $(MODVERSIONS))
118508Sthresh@nginx.com
1192385Sthresh@nginx.comDockerfile.%: ../../version template.Dockerfile
120508Sthresh@nginx.com	@echo "===> Building $@"
1211783Sthresh@videolan.org	cat template.Dockerfile | sed \
1221783Sthresh@videolan.org			-e 's,@@VERSION@@,$(VERSION),g' \
1232408Sthresh@nginx.com			-e 's,@@PATCHLEVEL@@,$(PATCHLEVEL),g' \
1242453Sthresh@nginx.com			-e 's,@@CONTAINER@@,$(CONTAINER_$*),g' \
1251783Sthresh@videolan.org			-e 's,@@CONFIGURE@@,$(CONFIGURE_$(call modname, $*)),g' \
1261783Sthresh@videolan.org			-e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \
1272385Sthresh@nginx.com			-e 's,@@RUN@@,$(RUN_$(call modname, $*)),g' \
1282530Sthresh@nginx.com			-e 's,@@MODULE_PREBUILD@@,$(MODULE_PREBUILD_$(call modname, $*)),g' \
1292533Sthresh@nginx.com			-e 's,@@MODULE@@,$*,g' \
130508Sthresh@nginx.com			> $@
131508Sthresh@nginx.com
132508Sthresh@nginx.combuild-%: Dockerfile.%
1332453Sthresh@nginx.com	docker pull $(CONTAINER_$*)
1341638Sthresh@nginx.com	docker build --no-cache -t unit:$(VERSION)-$* -f Dockerfile.$* .
135508Sthresh@nginx.com
1362384Sthresh@videolan.orglibrary:
1372415Sthresh@nginx.com	@echo "# this file is generated via https://github.com/nginx/unit/blob/$(shell git describe --always --abbrev=0 HEAD)/pkg/docker/Makefile"
1382384Sthresh@videolan.org	@echo ""
1392384Sthresh@videolan.org	@echo "Maintainers: Unit Docker Maintainers <docker-maint@nginx.com> (@nginx)"
1402384Sthresh@videolan.org	@echo "GitRepo: https://github.com/nginx/unit.git"
1412453Sthresh@nginx.com	@previous=""; \
1422453Sthresh@nginx.com	 for mod in $(MODVERSIONS); do \
1432384Sthresh@videolan.org		echo ""; \
1442453Sthresh@nginx.com		modname="$$( echo $$mod | tr -d '.0123456789-' )"; \
1452453Sthresh@nginx.com		TAGS="$$mod $${mod%%.*} $$modname" ; \
1462384Sthresh@videolan.org		TAGS="$$(echo $$TAGS | tr " " "\n" | sort -u -r | tr "\n" "," | sed "s/,/, /g")"; \
1472536Sthresh@nginx.com		if [ "$$previous" = "$$modname" ]; then \
1482453Sthresh@nginx.com			echo "Tags: $(VERSION)-$$mod, $$mod"; \
1492453Sthresh@nginx.com		else \
1502536Sthresh@nginx.com			if [ "$$mod" = "minimal" ]; then \
1512455Sthresh@nginx.com				echo "Tags: $(VERSION)-$$mod, $${TAGS%, }, latest"; \
1522455Sthresh@nginx.com			else \
1532455Sthresh@nginx.com				echo "Tags: $(VERSION)-$$mod, $${TAGS%, }"; \
1542455Sthresh@nginx.com			fi; \
1552453Sthresh@nginx.com		fi; \
1562384Sthresh@videolan.org		echo "Architectures: amd64, arm64v8"; \
1572415Sthresh@nginx.com		echo "GitFetch: refs/heads/branches/packaging"; \
1582384Sthresh@videolan.org		echo "GitCommit: $(shell git describe --always --abbrev=0 HEAD)"; \
1592384Sthresh@videolan.org		echo "Directory: pkg/docker"; \
1602384Sthresh@videolan.org		echo "File: Dockerfile.$$mod"; \
1612453Sthresh@nginx.com		previous=$$(echo $$mod | tr -d '.0123456789-'); \
1622384Sthresh@videolan.org	done
1632384Sthresh@videolan.org
1642537Sthresh@nginx.comdiff: $(addprefix diff-, $(MODVERSIONS))
1652537Sthresh@nginx.com
1662537Sthresh@nginx.comdiff-%:
1672537Sthresh@nginx.com	@echo container-diff diff --type file daemon://$(CONTAINER_$*) daemon://unit:$(VERSION)-$*
1682537Sthresh@nginx.com
1691783Sthresh@videolan.orgall: $(addprefix Dockerfile., $(MODVERSIONS))
170508Sthresh@nginx.com
171508Sthresh@nginx.comclean:
1722454Sthresh@nginx.com	rm -f Dockerfile.*
173508Sthresh@nginx.com
1742384Sthresh@videolan.org.PHONY: default build dockerfiles clean library
175