Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Node debian core variant #2058

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Build core base image
if: ${{ endsWith(matrix.variant, '-core') }}
uses: docker/build-push-action@v5
with:
push: false
load: true
context: .
file: ./${{ steps.short-version.outputs.result }}/${{ matrix.base }}/Dockerfile
tags: node:${{ matrix.version }}-${{ matrix.base }}

- name: Build image
uses: docker/build-push-action@v5
with:
Expand All @@ -91,7 +101,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
13 changes: 13 additions & 0 deletions 18/bookworm-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.1

COPY --from=node:18.20.1-bookworm-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:18.20.1-bookworm-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 18/bullseye-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.1

COPY --from=node:18.20.1-bullseye-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:18.20.1-bullseye-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 18/buster-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.1

COPY --from=node:18.20.1-buster-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:18.20.1-buster-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 20/bookworm-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.1

COPY --from=node:20.12.1-bookworm-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:20.12.1-bookworm-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 20/bullseye-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.1

COPY --from=node:20.12.1-bullseye-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:20.12.1-bullseye-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 20/buster-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.1

COPY --from=node:20.12.1-buster-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:20.12.1-buster-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 21/bookworm-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.2

COPY --from=node:21.7.2-bookworm-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:21.7.2-bookworm-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions 21/bullseye-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.2

COPY --from=node:21.7.2-bullseye-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:21.7.2-bullseye-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
13 changes: 13 additions & 0 deletions Dockerfile-debian-core.template
Original file line number Diff line number Diff line change
@@ -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-slim --link /usr/local/bin/ /usr/local/bin/
COPY --from=node:0.0.0-slim --link /usr/local/include/node/ /usr/local/include/node/

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "node" ]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions architectures
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions genMatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ const getDockerfileMatrixEntry = (file) => {

const version = getFullNodeVersionFromDockerfile(file);

// Specify the base image that needs to be built before the core one
if (variant.endsWith('-core')) {
const base = variant.replace('-core', '-slim')

return {
version,
variant,
base,
}
}

return {
version,
variant,
Expand Down
9 changes: 8 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}-${variant%'-core'}"'/' "${dockerfile}-tmp"

currentYarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${currentYarnVersion}"'/' "${dockerfile}-tmp"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -221,11 +224,15 @@ 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

cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
if ! is_debian_core "${variant}"; then
cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
fi
if [ "${update_version}" -eq 0 ] && [ "${update_variant}" -eq 0 ]; then
update_node_version "${baseuri}" "${versionnum}" "${template_file}" "${version}/${variant}/Dockerfile" "${variant}" &
pids+=($!)
Expand Down
52 changes: 52 additions & 0 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
"ppc64le",
"s390x"
],
"bookworm-core": [
"amd64",
"arm32v7",
"arm64v8",
"ppc64le",
"s390x"
],
"bullseye": [
"amd64",
"arm32v7",
Expand All @@ -51,6 +58,13 @@
"arm64v8",
"ppc64le",
"s390x"
],
"bullseye-core": [
"amd64",
"arm32v7",
"arm64v8",
"ppc64le",
"s390x"
]
}
},
Expand Down Expand Up @@ -93,6 +107,13 @@
"ppc64le",
"s390x"
],
"bookworm-core": [
"amd64",
"arm32v7",
"arm64v8",
"ppc64le",
"s390x"
],
"bullseye": [
"amd64",
"arm32v7",
Expand All @@ -107,6 +128,13 @@
"ppc64le",
"s390x"
],
"bullseye-core": [
"amd64",
"arm32v7",
"arm64v8",
"ppc64le",
"s390x"
],
"buster": [
"amd64",
"arm32v7",
Expand All @@ -116,6 +144,11 @@
"amd64",
"arm32v7",
"arm64v8"
],
"buster-core": [
"amd64",
"arm32v7",
"arm64v8"
]
}
},
Expand Down Expand Up @@ -158,6 +191,13 @@
"ppc64le",
"s390x"
],
"bookworm-core": [
"amd64",
"arm32v7",
"arm64v8",
"ppc64le",
"s390x"
],
"bullseye": [
"amd64",
"arm32v7",
Expand All @@ -172,6 +212,13 @@
"ppc64le",
"s390x"
],
"bullseye-core": [
"amd64",
"arm32v7",
"arm64v8",
"ppc64le",
"s390x"
],
"buster": [
"amd64",
"arm32v7",
Expand All @@ -181,6 +228,11 @@
"amd64",
"arm32v7",
"arm64v8"
],
"buster-core": [
"amd64",
"arm32v7",
"arm64v8"
]
}
}
Expand Down
Loading