Add example for Debian without npm or Yarn#2454
Add example for Debian without npm or Yarn#2454MikeMcC399 wants to merge 2 commits intonodejs:mainfrom
Conversation
f5fe189 to
b9f7af4
Compare
b9f7af4 to
7f4beab
Compare
Relative size-saving depends on the size of the custom app
|
I'll get round to a proper review later but out if curiousity what' the reason behind:
Does that cause problems? |
|
I'm a little surprised the savings are so small with this approach. Unlikely to be something that many people would go for (especially for v26 which isn't including yarn) but having the example is reasonable. |
That is described in https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals and https://packages.debian.org/trixie/dumb-init where it says: Package: dumb-init (1.2.5-3 and others)
|
It wouldn't motivate me personally in terms of size savings, however other people may have other criteria. Reducing vulnerabilities would be a better motive, as npm is regularly involved in new vulnerability discoveries. The motivation for adding this example is to provide the basis to close off the requests to remove npm and Yarn. If this can be merged, then I'll write up the justification to propose closing off the related issue(s). |
Description
A Debian example is added to Smaller images without npm/yarn to complement the existing Alpine example.
Motivation and Context
Issue #404 requests an image without npm nor Yarn. This is partially achieved by removing Yarn from all future Node.js Docker images based on the upcoming Node.js 26 release and other higher releases.
The npm package manager npm is part of the official Node.js distribution. If the role of Node.js Docker images is to package exactly what Node.js bundles in its releases, then npm must also be included.
Nevertheless, some users do not want to run their Docker image with a package manager to achieve a lower Docker image size or to harden their image against package manager vulnerabilities.
The Docker and Node.js Best Practices document, in the section Smaller images without npm/yarn, already provides an example for Alpine images, using a multi-stage build. The first stage builds the app with npm, then in a second run-time only Docker build stage, only the
appandnodedirectory are copied, without copying anynpmoryarnpackage manager directories.Testing Details
Add
"build": "ncc build index.js -o dist"topackage.jsonscriptsExample Output
Image sizes Debian
Image sizes Alpine (from PR #2410) testing steps
Types of changes
Checklist