From 177451d23144a4279c695a1d1341416fd74d3076 Mon Sep 17 00:00:00 2001 From: Christopher Horrell Date: Wed, 13 Aug 2025 17:20:03 -0400 Subject: [PATCH] Add Node.js v20 --- 20/Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ README.md | 2 +- spec/20/Dockerfile_spec.rb | 23 +++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 20/Dockerfile create mode 100644 spec/20/Dockerfile_spec.rb diff --git a/20/Dockerfile b/20/Dockerfile new file mode 100644 index 0000000..b9313d3 --- /dev/null +++ b/20/Dockerfile @@ -0,0 +1,37 @@ +FROM debian:trixie-slim + +ENV NPM_CONFIG_LOGLEVEL=info +ENV NODE_VERSION=20.19.4 + +# gpg keys listed at https://github.com/nodejs/node +RUN set -ex \ + && apt-get update \ + && apt-get install -y ca-certificates curl gnupg dirmngr xz-utils --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 5BE8A3F6C8A5C01D106C0AD820B1A390B168D356 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + CC68F5A3106FF448322E48ED27F5E38D5B0A215F \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + { gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" && gpg --batch --fingerprint "$key"; } || \ + { gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" && gpg --batch --fingerprint "$key"; } ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \ + && rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \ + && node --version \ + && npm --version + +CMD [ "node" ] \ No newline at end of file diff --git a/README.md b/README.md index e0bd67e..782e857 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ bundle exec rake The above will run Serverspec and using the docker-api gem it will -- Build a Docker image from the Docker file found in the top level directories (22) +- Build a Docker image from the Docker file found in the top level directories (20 and 22) - Create a container of that image, - Run the tests found in `spec/` on the container - Delete the images and containers if the test was successful diff --git a/spec/20/Dockerfile_spec.rb b/spec/20/Dockerfile_spec.rb new file mode 100644 index 0000000..f80dbc1 --- /dev/null +++ b/spec/20/Dockerfile_spec.rb @@ -0,0 +1,23 @@ +require 'serverspec' +require 'docker' +require 'node_tests' +require 'npm_tests' + +tag = ENV['TARGET_HOST'] + +describe "#{tag}" do + include Helpers + + before(:all) do + create_image(tag) + end + + test_node("20.19.4") + + test_npm + + after(:all) do + delete_image + end + +end