Add example for Debian without npm or Yarn#2454
Open
MikeMcC399 wants to merge 2 commits intonodejs:mainfrom
Open
Add example for Debian without npm or Yarn#2454MikeMcC399 wants to merge 2 commits intonodejs:mainfrom
MikeMcC399 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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