From 6d065eda41b466ededcc37f28da8a96f8d07abc2 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Tue, 2 Apr 2024 13:29:42 -0400 Subject: [PATCH] Add Node debian core variant --- .gitattributes | 3 ++ .github/workflows/build-test.yml | 2 ++ 18/bookworm-core/Dockerfile | 13 +++++++ 18/bookworm-core/docker-entrypoint.sh | 11 ++++++ 18/bullseye-core/Dockerfile | 13 +++++++ 18/bullseye-core/docker-entrypoint.sh | 11 ++++++ 18/buster-core/Dockerfile | 13 +++++++ 18/buster-core/docker-entrypoint.sh | 11 ++++++ 20/bookworm-core/Dockerfile | 13 +++++++ 20/bookworm-core/docker-entrypoint.sh | 11 ++++++ 20/bullseye-core/Dockerfile | 13 +++++++ 20/bullseye-core/docker-entrypoint.sh | 11 ++++++ 20/buster-core/Dockerfile | 13 +++++++ 20/buster-core/docker-entrypoint.sh | 11 ++++++ 21/bookworm-core/Dockerfile | 13 +++++++ 21/bookworm-core/docker-entrypoint.sh | 11 ++++++ 21/bullseye-core/Dockerfile | 13 +++++++ 21/bullseye-core/docker-entrypoint.sh | 11 ++++++ Dockerfile-debian-core.template | 13 +++++++ README.md | 5 +++ architectures | 10 +++--- functions.sh | 14 ++++++++ update.sh | 6 ++++ versions.json | 52 +++++++++++++++++++++++++++ 24 files changed, 292 insertions(+), 5 deletions(-) create mode 100644 18/bookworm-core/Dockerfile create mode 100755 18/bookworm-core/docker-entrypoint.sh create mode 100644 18/bullseye-core/Dockerfile create mode 100755 18/bullseye-core/docker-entrypoint.sh create mode 100644 18/buster-core/Dockerfile create mode 100755 18/buster-core/docker-entrypoint.sh create mode 100644 20/bookworm-core/Dockerfile create mode 100755 20/bookworm-core/docker-entrypoint.sh create mode 100644 20/bullseye-core/Dockerfile create mode 100755 20/bullseye-core/docker-entrypoint.sh create mode 100644 20/buster-core/Dockerfile create mode 100755 20/buster-core/docker-entrypoint.sh create mode 100644 21/bookworm-core/Dockerfile create mode 100755 21/bookworm-core/docker-entrypoint.sh create mode 100644 21/bullseye-core/Dockerfile create mode 100755 21/bullseye-core/docker-entrypoint.sh create mode 100644 Dockerfile-debian-core.template diff --git a/.gitattributes b/.gitattributes index 6313b56c57..21d328d7be 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ * text=auto eol=lf +/*/**/Dockerfile linguist-generated +/*/**/docker-entrypoint.sh linguist-generated +/Dockerfile*.template linguist-language=Dockerfile diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 4b1c51ed1a..39e3bfd21c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -91,7 +91,9 @@ jobs: [ "${output}" = 'success' ] - name: Test for npm + if: ${{ ! endsWith(matrix.variant, '-core') }} run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} npm --version - name: Test for yarn + if: ${{ ! endsWith(matrix.variant, '-core') }} run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version diff --git a/18/bookworm-core/Dockerfile b/18/bookworm-core/Dockerfile new file mode 100644 index 0000000000..860003d707 --- /dev/null +++ b/18/bookworm-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:bookworm-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 18.20.0 + +COPY --from=node:18.20.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:18.20.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/18/bookworm-core/docker-entrypoint.sh b/18/bookworm-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/18/bookworm-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/18/bullseye-core/Dockerfile b/18/bullseye-core/Dockerfile new file mode 100644 index 0000000000..f36b539fe1 --- /dev/null +++ b/18/bullseye-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:bullseye-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 18.20.0 + +COPY --from=node:18.20.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:18.20.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/18/bullseye-core/docker-entrypoint.sh b/18/bullseye-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/18/bullseye-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/18/buster-core/Dockerfile b/18/buster-core/Dockerfile new file mode 100644 index 0000000000..3aee8bfe4d --- /dev/null +++ b/18/buster-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:buster-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 18.20.0 + +COPY --from=node:18.20.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:18.20.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/18/buster-core/docker-entrypoint.sh b/18/buster-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/18/buster-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/20/bookworm-core/Dockerfile b/20/bookworm-core/Dockerfile new file mode 100644 index 0000000000..3c537dbab4 --- /dev/null +++ b/20/bookworm-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:bookworm-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 20.12.0 + +COPY --from=node:20.12.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:20.12.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/20/bookworm-core/docker-entrypoint.sh b/20/bookworm-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/20/bookworm-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/20/bullseye-core/Dockerfile b/20/bullseye-core/Dockerfile new file mode 100644 index 0000000000..8e9ed9eaae --- /dev/null +++ b/20/bullseye-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:bullseye-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 20.12.0 + +COPY --from=node:20.12.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:20.12.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/20/bullseye-core/docker-entrypoint.sh b/20/bullseye-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/20/bullseye-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/20/buster-core/Dockerfile b/20/buster-core/Dockerfile new file mode 100644 index 0000000000..58c8266882 --- /dev/null +++ b/20/buster-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:buster-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 20.12.0 + +COPY --from=node:20.12.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:20.12.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/20/buster-core/docker-entrypoint.sh b/20/buster-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/20/buster-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/21/bookworm-core/Dockerfile b/21/bookworm-core/Dockerfile new file mode 100644 index 0000000000..2a81f288b9 --- /dev/null +++ b/21/bookworm-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:bookworm-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 21.7.1 + +COPY --from=node:21.7.1 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:21.7.1 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/21/bookworm-core/docker-entrypoint.sh b/21/bookworm-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/21/bookworm-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/21/bullseye-core/Dockerfile b/21/bullseye-core/Dockerfile new file mode 100644 index 0000000000..2a1793fef8 --- /dev/null +++ b/21/bullseye-core/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:bullseye-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 21.7.1 + +COPY --from=node:21.7.1 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:21.7.1 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/21/bullseye-core/docker-entrypoint.sh b/21/bullseye-core/docker-entrypoint.sh new file mode 100755 index 0000000000..1b3116e53b --- /dev/null +++ b/21/bullseye-core/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +exec "$@" diff --git a/Dockerfile-debian-core.template b/Dockerfile-debian-core.template new file mode 100644 index 0000000000..1a8209a003 --- /dev/null +++ b/Dockerfile-debian-core.template @@ -0,0 +1,13 @@ +FROM debian:name-slim + +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +ENV NODE_VERSION 0.0.0 + +COPY --from=node:0.0.0 /usr/local/bin/ /usr/local/bin/ +COPY --from=node:0.0.0 /usr/local/include/node/ /usr/local/include/node/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD [ "node" ] diff --git a/README.md b/README.md index b86c29ca71..4eb8c31d5f 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The official Node.js docker image, made with love by the node community. - [`node:bullseye`](#nodebullseye) - [`node:bookworm`](#nodebookworm) - [`node:slim`](#nodeslim) + - [`node:core`](#nodecore) - [License](#license) - [Supported Docker versions](#supported-docker-versions) - [Supported Node.js versions](#supported-nodejs-versions) @@ -223,6 +224,10 @@ in an environment where *only* the Node.js image will be deployed and you have space constraints, we highly recommend using the default image of this repository. +### `node:core` + +This image is a variant of the slim image without npm or Yarn. + ## License [License information](https://github.com/nodejs/node/blob/master/LICENSE) for diff --git a/architectures b/architectures index 1ef81e6bb2..3bfdefa406 100644 --- a/architectures +++ b/architectures @@ -1,8 +1,8 @@ bashbrew-arch variants -amd64 alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim +amd64 alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core arm32v6 alpine3.18,alpine3.19 -arm32v7 alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim -arm64v8 alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim +arm32v7 alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core +arm64v8 alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core i386 alpine3.18,alpine3.19 -ppc64le alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim -s390x alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim +ppc64le alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core +s390x alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core diff --git a/functions.sh b/functions.sh index df1883f732..a50502e374 100755 --- a/functions.sh +++ b/functions.sh @@ -193,6 +193,20 @@ function is_debian_slim() { return 1 } +function is_debian_core() { + local variant + variant=$1 + shift + + IFS=' ' read -ra debianVersions <<< "$(get_config "./" "debian_versions")" + for d in "${debianVersions[@]}"; do + if [ "${d}-core" = "${variant}" ]; then + return 0 + fi + done + return 1 +} + function get_fork_name() { local version version=$1 diff --git a/update.sh b/update.sh index 9a321c800c..5514ba7f6a 100755 --- a/update.sh +++ b/update.sh @@ -134,6 +134,7 @@ function update_node_version() { sed -Ei -e 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "${dockerfile}-tmp" sed -Ei -e 's/^(ENV NODE_VERSION ).*/\1'"${nodeVersion}"'/' "${dockerfile}-tmp" + sed -Ei -e 's/^(COPY --from=node:)[^ ]*/\1'"${nodeVersion}"'/' "${dockerfile}-tmp" currentYarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)" sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${currentYarnVersion}"'/' "${dockerfile}-tmp" @@ -167,6 +168,8 @@ function update_node_version() { sed -Ei -e "s/(buildpack-deps:)name/\\1${variant}/" "${dockerfile}-tmp" elif is_debian_slim "${variant}"; then sed -Ei -e "s/(debian:)name-slim/\\1${variant}/" "${dockerfile}-tmp" + elif is_debian_core "${variant}"; then + sed -Ei -e "s/(debian:)name-slim/\\1${variant%"-core"}-slim/" "${dockerfile}-tmp" fi if diff -q "${dockerfile}-tmp" "${dockerfile}" > /dev/null; then @@ -211,6 +214,7 @@ for version in "${versions[@]}"; do fi for variant in "${variants[@]}"; do + # Skip non-docker directories [ -f "${version}/${variant}/Dockerfile" ] || continue @@ -221,6 +225,8 @@ for version in "${versions[@]}"; do template_file="${parentpath}/Dockerfile-debian.template" elif is_debian_slim "${variant}"; then template_file="${parentpath}/Dockerfile-slim.template" + elif is_debian_core "${variant}"; then + template_file="${parentpath}/Dockerfile-debian-core.template" elif is_alpine "${variant}"; then template_file="${parentpath}/Dockerfile-alpine.template" fi diff --git a/versions.json b/versions.json index 15e45e5f37..97f9fd11b8 100644 --- a/versions.json +++ b/versions.json @@ -38,6 +38,13 @@ "ppc64le", "s390x" ], + "bookworm-core": [ + "amd64", + "arm32v7", + "arm64v8", + "ppc64le", + "s390x" + ], "bullseye": [ "amd64", "arm32v7", @@ -51,6 +58,13 @@ "arm64v8", "ppc64le", "s390x" + ], + "bullseye-core": [ + "amd64", + "arm32v7", + "arm64v8", + "ppc64le", + "s390x" ] } }, @@ -93,6 +107,13 @@ "ppc64le", "s390x" ], + "bookworm-core": [ + "amd64", + "arm32v7", + "arm64v8", + "ppc64le", + "s390x" + ], "bullseye": [ "amd64", "arm32v7", @@ -107,6 +128,13 @@ "ppc64le", "s390x" ], + "bullseye-core": [ + "amd64", + "arm32v7", + "arm64v8", + "ppc64le", + "s390x" + ], "buster": [ "amd64", "arm32v7", @@ -116,6 +144,11 @@ "amd64", "arm32v7", "arm64v8" + ], + "buster-core": [ + "amd64", + "arm32v7", + "arm64v8" ] } }, @@ -158,6 +191,13 @@ "ppc64le", "s390x" ], + "bookworm-core": [ + "amd64", + "arm32v7", + "arm64v8", + "ppc64le", + "s390x" + ], "bullseye": [ "amd64", "arm32v7", @@ -172,6 +212,13 @@ "ppc64le", "s390x" ], + "bullseye-core": [ + "amd64", + "arm32v7", + "arm64v8", + "ppc64le", + "s390x" + ], "buster": [ "amd64", "arm32v7", @@ -181,6 +228,11 @@ "amd64", "arm32v7", "arm64v8" + ], + "buster-core": [ + "amd64", + "arm32v7", + "arm64v8" ] } }