-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Feedback before writing: bootstrap using node command #724
Comments
@kevynb Great start. Some thoughts:
|
I’m sorry for not having the time to open a proposer PR, here’s the “issue” version: Bootstrap container using node command8.X Bootstrap container using node command, avoid npm start ** TL;DR ** use Read More: Bootstrap container using node command, avoid npm start —————— Bootstrap container using node command instead of npmOne paragraph explainerWe are used to see code examples where folks start their app using Code exampleFROM node:12-slim AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production && npm clean cache --force
CMD ['node', 'server.js'] AntipatternsUsing npm start FROM node:12-slim AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production && npm clean cache --force
# don’t do that!
CMD “npm start” Using node in a single string will start a bash/ash shell process to execute your command. That is almost the same as using FROM node:12-slim AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production && npm clean cache --force
# don’t do that, it will start bash
CMD "node server.js" Starting with npm, here’s the process tree:
There is no advantage to those two extra process. Sources: https://maximorlov.com/process-signals-inside-docker-containers/ |
@kevynb Want me to copy to a PR or wait? Your call, I'll gladly do both:) |
I finally opened the PR #733 , thanks @goldbergyoni ! |
Context: This is used to share my initial draft of a new best practice to get feedback before writing it down.
Title: Bootsrap the code using 'node' command, avoid 'npm run' scripts
TL;DR:
Should we add code examples for non working cases?
Should we add a code example showing how to handle signals or is this not the subject here?
Links:
https://maximorlov.com/process-signals-inside-docker-containers/
https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#handling-kernel-signals
Sorry for the poor formatting, I’m doing this from my phone, I forgot my laptop for the weekend 😅
The text was updated successfully, but these errors were encountered: