1#!/usr/bin/make 2 3include ../../version 4include ../shasum.mak 5 6DEFAULT_VERSION := $(NXT_VERSION) 7 8VERSION ?= $(DEFAULT_VERSION) 9 10EXPORT_DIR := $(VERSION) 11 12MODULES ?= go jsc node perl php python ruby minimal 13 14VERSION_minimal ?= 15CONTAINER_minimal ?= debian:bullseye-slim 16CONFIGURE_minimal ?= 17INSTALL_minimal ?= version 18define COPY_minimal 19endef 20 21VERSION_go ?= 1.18 22CONTAINER_go ?= golang:$(VERSION_go) 23CONFIGURE_go ?= go --go-path=$$GOPATH 24INSTALL_go ?= go-install-src libunit-install 25define COPY_go 26COPY --from=BUILDER /usr/lib/\*-linux-gnu/libunit.a /tmp/\n\$ 27COPY --from=BUILDER /usr/include/nxt_* /usr/include/\n\$ 28COPY --from=BUILDER /go/src/ /go/src/ 29endef 30 31VERSION_jsc ?= 11 32CONTAINER_jsc ?= openjdk:$(VERSION_jsc)-jdk 33CONFIGURE_jsc ?= java --jars=/usr/share/unit-jsc-common/ 34INSTALL_jsc ?= java-shared-install java-install 35COPY_jsc = COPY --from=BUILDER /usr/share/unit-jsc-common/ /usr/share/unit-jsc-common/ 36 37VERSION_node ?= 16 38CONTAINER_node ?= node:$(VERSION_node) 39CONFIGURE_node ?= nodejs --node-gyp=/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp 40INSTALL_node ?= node node-install libunit-install 41define COPY_node 42COPY --from=BUILDER /usr/lib/\*-linux-gnu/libunit.a /tmp/\n\$ 43COPY --from=BUILDER /usr/include/nxt_* /usr/include/\n\$ 44COPY --from=BUILDER /usr/local/lib/node_modules/unit-http/ /usr/local/lib/node_modules/unit-http/ 45endef 46 47VERSION_perl ?= 5.34 48CONTAINER_perl ?= perl:$(VERSION_perl) 49CONFIGURE_perl ?= perl 50INSTALL_perl ?= perl-install 51COPY_perl = 52 53VERSION_php ?= 8.1 54CONTAINER_php ?= php:$(VERSION_php)-cli 55CONFIGURE_php ?= php 56INSTALL_php ?= php-install 57COPY_php = RUN ldconfig 58 59VERSION_python ?= 3.10 60CONTAINER_python ?= python:$(VERSION_python) 61CONFIGURE_python ?= python --config=/usr/local/bin/python3-config 62INSTALL_python ?= python3-install 63COPY_python = 64 65VERSION_ruby ?= 3.1 66CONTAINER_ruby ?= ruby:$(VERSION_ruby) 67CONFIGURE_ruby ?= ruby 68INSTALL_ruby ?= ruby-install 69COPY_ruby = RUN gem install rack 70 71default: 72 @echo "valid targets: all build dockerfiles push tag export clean" 73 74MODVERSIONS = $(foreach module,$(MODULES),$(module)$(VERSION_$(module))) 75 76modname = $(shell echo $1 | /usr/bin/tr -d '.01234567890-') 77 78dockerfiles: $(addprefix Dockerfile., $(MODVERSIONS)) 79build: $(addprefix build-,$(MODVERSIONS)) 80tag: $(addprefix tag-,$(MODVERSIONS)) 81push: $(addprefix push-,$(MODVERSIONS)) 82export: $(addsuffix .tar.gz,$(addprefix $(EXPORT_DIR)/nginx-unit-$(VERSION)-,$(MODVERSIONS))) $(addsuffix .tar.gz.sha512, $(addprefix $(EXPORT_DIR)/nginx-unit-$(VERSION)-,$(MODVERSIONS))) 83 84Dockerfile.%: ../../version 85 @echo "===> Building $@" 86 cat template.Dockerfile | sed \ 87 -e 's,@@VERSION@@,$(VERSION),g' \ 88 -e 's,@@CONTAINER@@,$(CONTAINER_$(call modname, $*)),g' \ 89 -e 's,@@CONFIGURE@@,$(CONFIGURE_$(call modname, $*)),g' \ 90 -e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \ 91 -e 's,@@COPY@@,$(COPY_$(call modname, $*)),g' \ 92 > $@ 93 94build-%: Dockerfile.% 95 docker pull $(CONTAINER_$(call modname, $*)) 96 docker build --no-cache -t unit:$(VERSION)-$* -f Dockerfile.$* . 97 98tag-%: build-% 99 docker tag unit:$(VERSION)-$* nginx/unit:$(VERSION)-$* 100 101push-%: tag-% 102 docker push nginx/unit:$(VERSION)-$* 103 104$(EXPORT_DIR): 105 mkdir -p $@ 106 107$(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz: $(EXPORT_DIR) tag-% 108 docker save nginx/unit:$(VERSION)-$* | gzip > $@ 109 110$(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz.sha512: $(EXPORT_DIR)/nginx-unit-$(VERSION)-%.tar.gz 111 $(SHA512SUM) $< | sed 's,$(EXPORT_DIR)/,,' > $@ 112 113all: $(addprefix Dockerfile., $(MODVERSIONS)) 114 115clean: 116 rm -f $(addprefix Dockerfile., $(MODVERSIONS)) 117 rm -rf $(EXPORT_DIR) 118 119.PHONY: default build dockerfiles push tag export clean 120