From e516d918ed47f456e38a44bdd1cf00fe862e1d85 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: introduced a "module prebuild" step. It's now used to install node-gyp on nodejs images. Starting from node:20, they no longer ship node-gyp that we require to build the modules with, so we need to install it manually. Fixes https://github.com/nginx/unit/issues/908. --- pkg/docker/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index cb801253..0dca751a 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -17,6 +17,7 @@ CONTAINER_minimal ?= debian:$(VARIANT)-slim CONFIGURE_minimal ?= INSTALL_minimal ?= version RUN_minimal ?= /bin/true +MODULE_PREBUILD_minimal ?= /bin/true VERSIONS_go ?= 1.20 VARIANT_go ?= $(VARIANT) @@ -24,6 +25,7 @@ $(foreach goversion, $(VERSIONS_go), $(eval CONTAINER_go$(goversion) = golang:$( CONFIGURE_go ?= go --go-path=$$GOPATH INSTALL_go ?= go-install-src libunit-install RUN_go ?= /bin/true +MODULE_PREBUILD_go ?= /bin/true VERSIONS_jsc ?= 11 VARIANT_jsc ?= jammy @@ -31,13 +33,15 @@ $(foreach jscversion, $(VERSIONS_jsc), $(eval CONTAINER_jsc$(jscversion) = eclip CONFIGURE_jsc ?= java --jars=/usr/share/unit-jsc-common/ INSTALL_jsc ?= java-shared-install java-install RUN_jsc ?= /bin/true +MODULE_PREBUILD_jsc ?= /bin/true VERSIONS_node ?= 18 VARIANT_node ?= $(VARIANT) $(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 +CONFIGURE_node ?= nodejs --node-gyp=/usr/local/bin/node-gyp INSTALL_node ?= node node-install libunit-install RUN_node ?= /bin/true +MODULE_PREBUILD_node ?= npm -g install node-gyp VERSIONS_perl ?= 5.36 VARIANT_perl ?= $(VARIANT) @@ -45,6 +49,7 @@ $(foreach perlversion, $(VERSIONS_perl), $(eval CONTAINER_perl$(perlversion) = p CONFIGURE_perl ?= perl INSTALL_perl ?= perl-install RUN_perl ?= /bin/true +MODULE_PREBUILD_perl ?= /bin/true VERSIONS_php ?= 8.2 VARIANT_php ?= cli-$(VARIANT) @@ -52,6 +57,7 @@ $(foreach phpversion, $(VERSIONS_php), $(eval CONTAINER_php$(phpversion) = php:$ CONFIGURE_php ?= php INSTALL_php ?= php-install RUN_php ?= ldconfig +MODULE_PREBUILD_php ?= /bin/true VERSIONS_python ?= 3.11 VARIANT_python ?= $(VARIANT) @@ -59,6 +65,7 @@ $(foreach pythonversion, $(VERSIONS_python), $(eval CONTAINER_python$(pythonvers CONFIGURE_python ?= python --config=/usr/local/bin/python3-config INSTALL_python ?= python3-install RUN_python ?= /bin/true +MODULE_PREBUILD_python ?= /bin/true VERSIONS_ruby ?= 3.2 VARIANT_ruby ?= $(VARIANT) @@ -66,6 +73,7 @@ $(foreach rubyversion, $(VERSIONS_ruby), $(eval CONTAINER_ruby$(rubyversion) = r CONFIGURE_ruby ?= ruby INSTALL_ruby ?= ruby-install RUN_ruby ?= gem install rack +MODULE_PREBUILD_ruby ?= /bin/true default: @echo "valid targets: all build dockerfiles library clean" @@ -86,6 +94,7 @@ Dockerfile.%: ../../version template.Dockerfile -e 's,@@CONFIGURE@@,$(CONFIGURE_$(call modname, $*)),g' \ -e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \ -e 's,@@RUN@@,$(RUN_$(call modname, $*)),g' \ + -e 's,@@MODULE_PREBUILD@@,$(MODULE_PREBUILD_$(call modname, $*)),g' \ > $@ build-%: Dockerfile.% -- cgit From 5ed7dd53c1630d106793f3a03f4afd92212f7f88 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: added wasm variant. --- pkg/docker/Makefile | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index 0dca751a..3373f8b2 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -8,7 +8,7 @@ DEFAULT_VERSION := $(NXT_VERSION) VERSION ?= $(DEFAULT_VERSION) PATCHLEVEL ?= 1 -MODULES ?= go jsc node perl php python ruby +MODULES ?= go jsc node perl php python ruby wasm VARIANT ?= bullseye @@ -75,10 +75,39 @@ INSTALL_ruby ?= ruby-install RUN_ruby ?= gem install rack MODULE_PREBUILD_ruby ?= /bin/true +VERSIONS_wasm ?= +CONTAINER_wasm ?= debian:$(VARIANT)-slim +CONFIGURE_wasm ?= wasm --include-path=\`pwd\`/pkg/contrib/wasmtime/crates/c-api/include --lib-path=/usr/lib/\$$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ +INSTALL_wasm ?= wasm-install +RUN_wasm ?= /bin/true +define MODULE_PREBUILD_wasm +export RUST_VERSION=1.71.0 \\\n \ +\ \ \ \&\& export RUSTUP_HOME=/usr/src/unit/rustup \\\n \ +\ \ \ \&\& export CARGO_HOME=/usr/src/unit/cargo \\\n \ +\ \ \ \&\& export PATH=/usr/src/unit/cargo/bin:\$$PATH \\\n \ +\ \ \ \&\& dpkgArch="\$$\(dpkg --print-architecture\)" \\\n \ +\ \ \ \&\& case "\$${dpkgArch##*-}" in \\\n \ +\ \ \ \ \ \ amd64\) rustArch="x86_64-unknown-linux-gnu"; rustupSha256="0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db" ;; \\\n \ +\ \ \ \ \ \ arm64\) rustArch="aarch64-unknown-linux-gnu"; rustupSha256="673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800" ;; \\\n \ +\ \ \ \ \ \ *\) echo \>\&2 "unsupported architecture: \$${dpkgArch}"; exit 1 ;; \\\n \ +\ \ \ \esac \\\n \ +\ \ \ \&\& url="https://static.rust-lang.org/rustup/archive/1.26.0/\$${rustArch}/rustup-init" \\\n \ +\ \ \ \&\& curl -L -O "\$$url" \\\n \ +\ \ \ \&\& echo "\$${rustupSha256} *rustup-init" | sha256sum -c - \\\n \ +\ \ \ \&\& chmod +x rustup-init \\\n \ +\ \ \ \&\& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain \$$RUST_VERSION --default-host \$${rustArch} \\\n \ +\ \ \ \&\& rm rustup-init \\\n \ +\ \ \ \&\& rustup --version \\\n \ +\ \ \ \&\& cargo --version \\\n \ +\ \ \ \&\& rustc --version \\\n \ +\ \ \ \&\& make -C pkg/contrib .wasmtime \\\n \ +\ \ \ \&\& install -pm 755 pkg/contrib/wasmtime/target/release/libwasmtime.so /usr/lib/\$$\(dpkg-architecture -q DEB_HOST_MULTIARCH\)/ +endef + default: @echo "valid targets: all build dockerfiles library clean" -MODVERSIONS = $(foreach module, $(MODULES), $(foreach modversion, $(shell for v in $(VERSIONS_$(module)); do echo $$v; done | sort -r), $(module)$(modversion))) minimal +MODVERSIONS = $(foreach module, $(MODULES), $(foreach modversion, $(shell for v in $(VERSIONS_$(module)); do echo $$v; done | sort -r), $(module)$(modversion))) wasm minimal modname = $(shell echo $1 | /usr/bin/tr -d '.01234567890-') -- cgit From 3562c68ce7040b56da5533d8dd4458cb54b9eede Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: added meaningful title to metadata. --- pkg/docker/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index 3373f8b2..6ec3f58b 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -124,6 +124,7 @@ Dockerfile.%: ../../version template.Dockerfile -e 's,@@INSTALL@@,$(INSTALL_$(call modname, $*)),g' \ -e 's,@@RUN@@,$(RUN_$(call modname, $*)),g' \ -e 's,@@MODULE_PREBUILD@@,$(MODULE_PREBUILD_$(call modname, $*)),g' \ + -e 's,@@MODULE@@,$*,g' \ > $@ build-%: Dockerfile.% -- cgit From c79c60be1c83c268b65b167935448b86ee4c5f98 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: bumped language versions. --- pkg/docker/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index 6ec3f58b..742f6244 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -19,7 +19,7 @@ INSTALL_minimal ?= version RUN_minimal ?= /bin/true MODULE_PREBUILD_minimal ?= /bin/true -VERSIONS_go ?= 1.20 +VERSIONS_go ?= 1.20 1.21 VARIANT_go ?= $(VARIANT) $(foreach goversion, $(VERSIONS_go), $(eval CONTAINER_go$(goversion) = golang:$(goversion)-$(VARIANT_go))) CONFIGURE_go ?= go --go-path=$$GOPATH @@ -35,7 +35,7 @@ INSTALL_jsc ?= java-shared-install java-install RUN_jsc ?= /bin/true MODULE_PREBUILD_jsc ?= /bin/true -VERSIONS_node ?= 18 +VERSIONS_node ?= 18 20 VARIANT_node ?= $(VARIANT) $(foreach nodeversion, $(VERSIONS_node), $(eval CONTAINER_node$(nodeversion) = node:$(nodeversion)-$(VARIANT_node))) CONFIGURE_node ?= nodejs --node-gyp=/usr/local/bin/node-gyp @@ -43,7 +43,7 @@ INSTALL_node ?= node node-install libunit-install RUN_node ?= /bin/true MODULE_PREBUILD_node ?= npm -g install node-gyp -VERSIONS_perl ?= 5.36 +VERSIONS_perl ?= 5.36 5.38 VARIANT_perl ?= $(VARIANT) $(foreach perlversion, $(VERSIONS_perl), $(eval CONTAINER_perl$(perlversion) = perl:$(perlversion)-$(VARIANT_perl))) CONFIGURE_perl ?= perl -- cgit From 78a473743d98cd74dd3408a6a7800ca0d3c1a697 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: be POSIX-compliant in the library creation script. --- pkg/docker/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index 742f6244..e3a48cff 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -142,10 +142,10 @@ library: modname="$$( echo $$mod | tr -d '.0123456789-' )"; \ TAGS="$$mod $${mod%%.*} $$modname" ; \ TAGS="$$(echo $$TAGS | tr " " "\n" | sort -u -r | tr "\n" "," | sed "s/,/, /g")"; \ - if [ "$$previous" == "$$modname" ]; then \ + if [ "$$previous" = "$$modname" ]; then \ echo "Tags: $(VERSION)-$$mod, $$mod"; \ else \ - if [ "$$mod" == "minimal" ]; then \ + if [ "$$mod" = "minimal" ]; then \ echo "Tags: $(VERSION)-$$mod, $${TAGS%, }, latest"; \ else \ echo "Tags: $(VERSION)-$$mod, $${TAGS%, }"; \ -- cgit From c1f0aeaea4ab15073290e1677e23cd027da1b375 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: added a container-diff helper. It's useful to check whether resulting images have unexpected build leftovers. Requires https://github.com/GoogleContainerTools/container-diff in $PATH. --- pkg/docker/Makefile | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index e3a48cff..bf4e67f2 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -159,6 +159,11 @@ library: previous=$$(echo $$mod | tr -d '.0123456789-'); \ done +diff: $(addprefix diff-, $(MODVERSIONS)) + +diff-%: + @echo container-diff diff --type file daemon://$(CONTAINER_$*) daemon://unit:$(VERSION)-$* + all: $(addprefix Dockerfile., $(MODVERSIONS)) clean: -- cgit From 4caf3abbe41c55ac654f392b5f24245383bf5338 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: remove npm caches in node images. --- pkg/docker/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index bf4e67f2..9cf08719 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -40,7 +40,7 @@ VARIANT_node ?= $(VARIANT) $(foreach nodeversion, $(VERSIONS_node), $(eval CONTAINER_node$(nodeversion) = node:$(nodeversion)-$(VARIANT_node))) CONFIGURE_node ?= nodejs --node-gyp=/usr/local/bin/node-gyp INSTALL_node ?= node node-install libunit-install -RUN_node ?= /bin/true +RUN_node ?= rm -rf /root/.cache/ \&\& rm -rf /root/.npm MODULE_PREBUILD_node ?= npm -g install node-gyp VERSIONS_perl ?= 5.36 5.38 -- cgit From 7af9f1a175e3dc7f92b6d5dedf5e936bebe490cd Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: remove maven caches in jsc images. --- pkg/docker/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index 9cf08719..feb6eb06 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -32,7 +32,7 @@ VARIANT_jsc ?= jammy $(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 +RUN_jsc ?= rm -rf /root/.m2 MODULE_PREBUILD_jsc ?= /bin/true VERSIONS_node ?= 18 20 -- cgit From 45bfba04bc62b9dba523cdbd20bcf9e6e4348bdf Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 22 Aug 2023 14:55:10 -0700 Subject: Docker: remove gem caches in ruby images. --- pkg/docker/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/docker/Makefile') diff --git a/pkg/docker/Makefile b/pkg/docker/Makefile index feb6eb06..237228a9 100644 --- a/pkg/docker/Makefile +++ b/pkg/docker/Makefile @@ -72,7 +72,7 @@ VARIANT_ruby ?= $(VARIANT) $(foreach rubyversion, $(VERSIONS_ruby), $(eval CONTAINER_ruby$(rubyversion) = ruby:$(rubyversion)-$(VARIANT_ruby))) CONFIGURE_ruby ?= ruby INSTALL_ruby ?= ruby-install -RUN_ruby ?= gem install rack +RUN_ruby ?= gem install rack \&\& rm -rf /root/.local MODULE_PREBUILD_ruby ?= /bin/true VERSIONS_wasm ?= -- cgit