Skip to content

Commit 39f78db

Browse files
Add Node debian core variant
1 parent b016843 commit 39f78db

File tree

16 files changed

+224
-6
lines changed

16 files changed

+224
-6
lines changed

.github/workflows/build-test.yml

+12
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ jobs:
6868
- name: Checkout
6969
uses: actions/checkout@v4
7070

71+
- name: Build core base image
72+
if: ${{ endsWith(matrix.variant, '-core') }}
73+
uses: docker/build-push-action@v5
74+
with:
75+
push: false
76+
load: true
77+
context: .
78+
file: ./${{ steps.short-version.outputs.result }}/${{ matrix.base }}/Dockerfile
79+
tags: node:${{ matrix.version }}-${{ matrix.base }}
80+
7181
- name: Build image
7282
uses: docker/build-push-action@v5
7383
with:
@@ -91,7 +101,9 @@ jobs:
91101
[ "${output}" = 'success' ]
92102
93103
- name: Test for npm
104+
if: ${{ ! endsWith(matrix.variant, '-core') }}
94105
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} npm --version
95106

96107
- name: Test for yarn
108+
if: ${{ ! endsWith(matrix.variant, '-core') }}
97109
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version

18/bookworm-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:bookworm-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 18.20.1
7+
8+
COPY --from=node:18.20.1-bookworm-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:18.20.1-bookworm-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

18/bullseye-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:bullseye-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 18.20.1
7+
8+
COPY --from=node:18.20.1-bullseye-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:18.20.1-bullseye-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

18/buster-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:buster-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 18.20.1
7+
8+
COPY --from=node:18.20.1-buster-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:18.20.1-buster-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

20/bookworm-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:bookworm-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 20.12.1
7+
8+
COPY --from=node:20.12.1-bookworm-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:20.12.1-bookworm-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

20/bullseye-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:bullseye-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 20.12.1
7+
8+
COPY --from=node:20.12.1-bullseye-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:20.12.1-bullseye-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

20/buster-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:buster-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 20.12.1
7+
8+
COPY --from=node:20.12.1-buster-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:20.12.1-buster-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

21/bookworm-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:bookworm-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 21.7.2
7+
8+
COPY --from=node:21.7.2-bookworm-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:21.7.2-bookworm-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

21/bullseye-core/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:bullseye-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 21.7.2
7+
8+
COPY --from=node:21.7.2-bullseye-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:21.7.2-bullseye-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

Dockerfile-debian-core.template

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:name-slim
2+
3+
RUN groupadd --gid 1000 node \
4+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
5+
6+
ENV NODE_VERSION 0.0.0
7+
8+
COPY --from=node:0.0.0-slim --link /usr/local/bin/ /usr/local/bin/
9+
COPY --from=node:0.0.0-slim --link /usr/local/include/node/ /usr/local/include/node/
10+
11+
ENTRYPOINT ["docker-entrypoint.sh"]
12+
13+
CMD [ "node" ]

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The official Node.js docker image, made with love by the node community.
2727
- [`node:bullseye`](#nodebullseye)
2828
- [`node:bookworm`](#nodebookworm)
2929
- [`node:slim`](#nodeslim)
30+
- [`node:core`](#nodecore)
3031
- [License](#license)
3132
- [Supported Docker versions](#supported-docker-versions)
3233
- [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
223224
space constraints, we highly recommend using the default image of this
224225
repository.
225226

227+
### `node:core`
228+
229+
This image is a variant of the slim image without npm or Yarn.
230+
226231
## License
227232

228233
[License information](https://github.com/nodejs/node/blob/master/LICENSE) for

architectures

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
bashbrew-arch variants
2-
amd64 alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim
2+
amd64 alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core
33
arm32v6 alpine3.18,alpine3.19
4-
arm32v7 alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim
5-
arm64v8 alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim
4+
arm32v7 alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core
5+
arm64v8 alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core
66
i386 alpine3.18,alpine3.19
7-
ppc64le alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim
8-
s390x alpine3.18,alpine3.19,bookworm,bookworm-slim,bullseye,bullseye-slim,buster,buster-slim
7+
ppc64le alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core
8+
s390x alpine3.18,alpine3.19,bookworm,bookworm-slim,bookworm-core,bullseye,bullseye-slim,bullseye-core,buster,buster-slim,buster-core

functions.sh

+14
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ function is_debian_slim() {
193193
return 1
194194
}
195195

196+
function is_debian_core() {
197+
local variant
198+
variant=$1
199+
shift
200+
201+
IFS=' ' read -ra debianVersions <<< "$(get_config "./" "debian_versions")"
202+
for d in "${debianVersions[@]}"; do
203+
if [ "${d}-core" = "${variant}" ]; then
204+
return 0
205+
fi
206+
done
207+
return 1
208+
}
209+
196210
function get_fork_name() {
197211
local version
198212
version=$1

genMatrix.js

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ const getDockerfileMatrixEntry = (file) => {
6060

6161
const version = getFullNodeVersionFromDockerfile(file);
6262

63+
// Specify the base image that needs to be built before the core one
64+
if (variant.endsWith('-core')) {
65+
const base = variant.replace('-core', '-slim')
66+
67+
return {
68+
version,
69+
variant,
70+
base,
71+
}
72+
}
73+
6374
return {
6475
version,
6576
variant,

update.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function update_node_version() {
134134

135135
sed -Ei -e 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "${dockerfile}-tmp"
136136
sed -Ei -e 's/^(ENV NODE_VERSION ).*/\1'"${nodeVersion}"'/' "${dockerfile}-tmp"
137+
sed -Ei -e 's/^(COPY --from=node:)[^-]*/\1'"${nodeVersion}-${variant%'-core'}"'/' "${dockerfile}-tmp"
137138

138139
currentYarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
139140
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${currentYarnVersion}"'/' "${dockerfile}-tmp"
@@ -167,6 +168,8 @@ function update_node_version() {
167168
sed -Ei -e "s/(buildpack-deps:)name/\\1${variant}/" "${dockerfile}-tmp"
168169
elif is_debian_slim "${variant}"; then
169170
sed -Ei -e "s/(debian:)name-slim/\\1${variant}/" "${dockerfile}-tmp"
171+
elif is_debian_core "${variant}"; then
172+
sed -Ei -e "s/(debian:)name-slim/\\1${variant%"-core"}-slim/" "${dockerfile}-tmp"
170173
fi
171174

172175
if diff -q "${dockerfile}-tmp" "${dockerfile}" > /dev/null; then
@@ -221,11 +224,15 @@ for version in "${versions[@]}"; do
221224
template_file="${parentpath}/Dockerfile-debian.template"
222225
elif is_debian_slim "${variant}"; then
223226
template_file="${parentpath}/Dockerfile-slim.template"
227+
elif is_debian_core "${variant}"; then
228+
template_file="${parentpath}/Dockerfile-debian-core.template"
224229
elif is_alpine "${variant}"; then
225230
template_file="${parentpath}/Dockerfile-alpine.template"
226231
fi
227232

228-
cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
233+
if ! is_debian_core "${variant}"; then
234+
cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
235+
fi
229236
if [ "${update_version}" -eq 0 ] && [ "${update_variant}" -eq 0 ]; then
230237
update_node_version "${baseuri}" "${versionnum}" "${template_file}" "${version}/${variant}/Dockerfile" "${variant}" &
231238
pids+=($!)

versions.json

+52
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
"ppc64le",
3939
"s390x"
4040
],
41+
"bookworm-core": [
42+
"amd64",
43+
"arm32v7",
44+
"arm64v8",
45+
"ppc64le",
46+
"s390x"
47+
],
4148
"bullseye": [
4249
"amd64",
4350
"arm32v7",
@@ -51,6 +58,13 @@
5158
"arm64v8",
5259
"ppc64le",
5360
"s390x"
61+
],
62+
"bullseye-core": [
63+
"amd64",
64+
"arm32v7",
65+
"arm64v8",
66+
"ppc64le",
67+
"s390x"
5468
]
5569
}
5670
},
@@ -93,6 +107,13 @@
93107
"ppc64le",
94108
"s390x"
95109
],
110+
"bookworm-core": [
111+
"amd64",
112+
"arm32v7",
113+
"arm64v8",
114+
"ppc64le",
115+
"s390x"
116+
],
96117
"bullseye": [
97118
"amd64",
98119
"arm32v7",
@@ -107,6 +128,13 @@
107128
"ppc64le",
108129
"s390x"
109130
],
131+
"bullseye-core": [
132+
"amd64",
133+
"arm32v7",
134+
"arm64v8",
135+
"ppc64le",
136+
"s390x"
137+
],
110138
"buster": [
111139
"amd64",
112140
"arm32v7",
@@ -116,6 +144,11 @@
116144
"amd64",
117145
"arm32v7",
118146
"arm64v8"
147+
],
148+
"buster-core": [
149+
"amd64",
150+
"arm32v7",
151+
"arm64v8"
119152
]
120153
}
121154
},
@@ -158,6 +191,13 @@
158191
"ppc64le",
159192
"s390x"
160193
],
194+
"bookworm-core": [
195+
"amd64",
196+
"arm32v7",
197+
"arm64v8",
198+
"ppc64le",
199+
"s390x"
200+
],
161201
"bullseye": [
162202
"amd64",
163203
"arm32v7",
@@ -172,6 +212,13 @@
172212
"ppc64le",
173213
"s390x"
174214
],
215+
"bullseye-core": [
216+
"amd64",
217+
"arm32v7",
218+
"arm64v8",
219+
"ppc64le",
220+
"s390x"
221+
],
175222
"buster": [
176223
"amd64",
177224
"arm32v7",
@@ -181,6 +228,11 @@
181228
"amd64",
182229
"arm32v7",
183230
"arm64v8"
231+
],
232+
"buster-core": [
233+
"amd64",
234+
"arm32v7",
235+
"arm64v8"
184236
]
185237
}
186238
}

0 commit comments

Comments
 (0)