Skip to content

Update Dockerizing guide to adhere to best practice #2293

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

Merged
merged 2 commits into from
Jun 29, 2019
Merged

Update Dockerizing guide to adhere to best practice #2293

merged 2 commits into from
Jun 29, 2019

Conversation

kaimallea
Copy link
Contributor

Hey y'all,

TL;DR - This PR updates the Dockerizing a Node.js web app guide to adhere to an official best practice of using node server.js instead of npm start inside of a Docker container.

Longer version:

The current Dockerizing a Node.js web app guide links to the official Node.js Docker Best Practices Guide that currently recommends avoiding the use of npm start for two reasons:

  1. Reduces the number of processes running inside of your container.
  2. Enable exit signals such as SIGTERM and SIGINT to be received by the Node.js process instead of npm swallowing them.

There are currently ~54,000 public Dockerfiles on GitHub not following this practice.

This PR updates the former guide to adhere to latter guide's best practice.

Additionally, the guide references "latest LTS" that points to 8, this updates that to 10

Additional Question:

How should I handle translations? The translation guide in this repo doesn't seem to apply to the guides pages, so I didn't update the corresponding paragraph of text for the locales that weren't already english.

@Trott
Copy link
Member

Trott commented Jun 25, 2019

/ping @nodejs/docker


```docker
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking perhaps but maybe this should be script.js or index.js since not every node app is a server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Laurent, thanks for the feedback. It should stay as-is because the guide, as it is written today, is a step-by-step guide that explicitly sets up a server and instructs the reader to create server.js. This PR is simply updating the pattern in the code without changing the scope of guide itself. Here's a link to the guide for reference.

available from the [Docker Hub](https://hub.docker.com/):

```docker
FROM node:8
FROM node:10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be node:lts instead of hard coding a version number, not sure if it should be recommended or not, though

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it should not. It's problematic in the same way latest is.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're currently having this discussion in PR #2953. Can you elaborate on this? I clearly see there might be issues using the latest tag, but I don't understand in what way this might be problematic in the same way latest would be.

@kaimallea
Copy link
Contributor Author

Is this good to go? 🚀

@SEWeiTung SEWeiTung merged commit b0dd55c into nodejs:master Jun 29, 2019
@kaimallea kaimallea deleted the kai/update-docker-guide branch July 19, 2019 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants