diff options
author | Konstantin Pavlov <thresh@nginx.com> | 2023-05-05 17:19:55 -0700 |
---|---|---|
committer | Konstantin Pavlov <thresh@nginx.com> | 2023-05-05 17:19:55 -0700 |
commit | 6e548cbb30c0035b0d377dced7564522fba4eff3 (patch) | |
tree | 0cd05d0accc20c04fefb0a875dabc963d200256b | |
parent | 7a77f48a25f4f719c51ed83dac9bf5dd844ba3f3 (diff) | |
download | unit-6e548cbb30c0035b0d377dced7564522fba4eff3.tar.gz unit-6e548cbb30c0035b0d377dced7564522fba4eff3.tar.bz2 |
Docker: added a way to generate multiple versions of an image.
-rw-r--r-- | pkg/docker/Makefile | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index 5b1f4f20..41c22171 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -10,61 +10,61 @@ PATCHLEVEL ?= 1 EXPORT_DIR := $(VERSION) -MODULES ?= go jsc node perl php python ruby minimal +MODULES ?= go jsc node perl php python ruby VARIANT ?= bullseye -VERSION_minimal ?= +VERSIONS_minimal ?= CONTAINER_minimal ?= debian:$(VARIANT)-slim CONFIGURE_minimal ?= INSTALL_minimal ?= version RUN_minimal ?= /bin/true -VERSION_go ?= 1.20 +VERSIONS_go ?= 1.20 VARIANT_go ?= $(VARIANT) -CONTAINER_go ?= golang:$(VERSION_go)-$(VARIANT_go) +$(foreach goversion, $(VERSIONS_go), $(eval CONTAINER_go$(goversion) = golang:$(goversion)-$(VARIANT_go))) CONFIGURE_go ?= go --go-path=$$GOPATH INSTALL_go ?= go-install-src libunit-install RUN_go ?= /bin/true -VERSION_jsc ?= 11 +VERSIONS_jsc ?= 11 VARIANT_jsc ?= jammy -CONTAINER_jsc ?= eclipse-temurin:$(VERSION_jsc)-jdk-$(VARIANT_jsc) +$(foreach jscversion, $(VERSIONS_jsc), $(eval CONTAINER_jsc$(jscversion) = eclipse-temurin:$(jscversion)-jdk-$(VARIANT_jsc))) CONFIGURE_jsc ?= java --jars=/usr/share/unit-jsc-common/ INSTALL_jsc ?= java-shared-install java-install RUN_jsc ?= /bin/true -VERSION_node ?= 18 +VERSIONS_node ?= 18 VARIANT_node ?= $(VARIANT) -CONTAINER_node ?= node:$(VERSION_node)-$(VARIANT_node) +$(foreach nodeversion, $(VERSIONS_node), $(eval CONTAINER_node$(nodeversion) = node:$(nodeversion)-$(VARIANT_node))) CONFIGURE_node ?= nodejs --node-gyp=/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp INSTALL_node ?= node node-install libunit-install RUN_node ?= /bin/true -VERSION_perl ?= 5.36 +VERSIONS_perl ?= 5.36 VARIANT_perl ?= $(VARIANT) -CONTAINER_perl ?= perl:$(VERSION_perl)-$(VARIANT_perl) +$(foreach perlversion, $(VERSIONS_perl), $(eval CONTAINER_perl$(perlversion) = perl:$(perlversion)-$(VARIANT_perl))) CONFIGURE_perl ?= perl INSTALL_perl ?= perl-install RUN_perl ?= /bin/true -VERSION_php ?= 8.2 +VERSIONS_php ?= 8.2 VARIANT_php ?= cli-$(VARIANT) -CONTAINER_php ?= php:$(VERSION_php)-$(VARIANT_php) +$(foreach phpversion, $(VERSIONS_php), $(eval CONTAINER_php$(phpversion) = php:$(phpversion)-$(VARIANT_php))) CONFIGURE_php ?= php INSTALL_php ?= php-install RUN_php ?= ldconfig -VERSION_python ?= 3.11 +VERSIONS_python ?= 3.11 VARIANT_python ?= $(VARIANT) -CONTAINER_python ?= python:$(VERSION_python)-$(VARIANT_python) +$(foreach pythonversion, $(VERSIONS_python), $(eval CONTAINER_python$(pythonversion) = python:$(pythonversion)-$(VARIANT_python))) CONFIGURE_python ?= python --config=/usr/local/bin/python3-config INSTALL_python ?= python3-install RUN_python ?= /bin/true -VERSION_ruby ?= 3.2 +VERSIONS_ruby ?= 3.2 VARIANT_ruby ?= $(VARIANT) -CONTAINER_ruby ?= ruby:$(VERSION_ruby)-$(VARIANT_ruby) +$(foreach rubyversion, $(VERSIONS_ruby), $(eval CONTAINER_ruby$(rubyversion) = ruby:$(rubyversion)-$(VARIANT_ruby))) CONFIGURE_ruby ?= ruby INSTALL_ruby ?= ruby-install RUN_ruby ?= gem install rack @@ -72,26 +72,26 @@ RUN_ruby ?= gem install rack default: @echo "valid targets: all build dockerfiles clean" -MODVERSIONS = $(foreach module,$(MODULES),$(module)$(VERSION_$(module))) +MODVERSIONS = $(foreach module, $(MODULES), $(foreach modversion, $(shell for v in $(VERSIONS_$(module)); do echo $$v; done | sort -r), $(module)$(modversion))) minimal modname = $(shell echo $1 | /usr/bin/tr -d '.01234567890-') dockerfiles: $(addprefix Dockerfile., $(MODVERSIONS)) -build: $(addprefix build-,$(MODVERSIONS)) +build: $(addprefix build-, $(MODVERSIONS)) Dockerfile.%: ../../version template.Dockerfile @echo "===> Building $@" cat template.Dockerfile | sed \ -e 's,@@VERSION@@,$(VERSION),g' \ -e 's,@@PATCHLEVEL@@,$(PATCHLEVEL),g' \ - -e 's,@@CONTAINER@@,$(CONTAINER_$(call modname, $*)),g' \ + -e 's,@@CONTAINER@@,$(CONTAINER_$*),g' \ -e 's,@@CONFIGURE@@,$(CONFIGURE_$(call modname, $*)),g' \ -e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \ -e 's,@@RUN@@,$(RUN_$(call modname, $*)),g' \ > $@ build-%: Dockerfile.% - docker pull $(CONTAINER_$(call modname, $*)) + docker pull $(CONTAINER_$*) docker build --no-cache -t unit:$(VERSION)-$* -f Dockerfile.$* . library: @@ -99,16 +99,23 @@ library: @echo "" @echo "Maintainers: Unit Docker Maintainers <docker-maint@nginx.com> (@nginx)" @echo "GitRepo: https://github.com/nginx/unit.git" - @for mod in $(MODVERSIONS); do \ + @previous=""; \ + for mod in $(MODVERSIONS); do \ echo ""; \ - TAGS="$$mod $${mod%%.*} $$( echo $$mod | tr -d '.0123456789-' )"; \ + modname="$$( echo $$mod | tr -d '.0123456789-' )"; \ + TAGS="$$mod $${mod%%.*} $$modname" ; \ TAGS="$$(echo $$TAGS | tr " " "\n" | sort -u -r | tr "\n" "," | sed "s/,/, /g")"; \ - echo "Tags: $(VERSION)-$$mod, $${TAGS%, }"; \ + if [ "$$previous" == "$$modname" ]; then \ + echo "Tags: $(VERSION)-$$mod, $$mod"; \ + else \ + echo "Tags: $(VERSION)-$$mod, $${TAGS%, }"; \ + fi; \ echo "Architectures: amd64, arm64v8"; \ echo "GitFetch: refs/heads/branches/packaging"; \ echo "GitCommit: $(shell git describe --always --abbrev=0 HEAD)"; \ echo "Directory: pkg/docker"; \ echo "File: Dockerfile.$$mod"; \ + previous=$$(echo $$mod | tr -d '.0123456789-'); \ done all: $(addprefix Dockerfile., $(MODVERSIONS)) |