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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions locale/en/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ touch Dockerfile
Open the `Dockerfile` in your favorite text editor

The first thing we need to do is define from what image we want to build from.
Here we will use the latest LTS (long term support) version `8` of `node`
Here we will use the latest LTS (long term support) version `10` of `node`
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.

```

Next we create a directory to hold the application code inside the image, this
Expand Down Expand Up @@ -134,17 +134,16 @@ EXPOSE 8080
```

Last but not least, define the command to run your app using `CMD` which defines
your runtime. Here we will use the basic `npm start` which will run
`node server.js` to start your server:
your runtime. Here we will use `node server.js` to start your server:

```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.

```

Your `Dockerfile` should now look like this:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -162,7 +161,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

## .dockerignore file
Expand Down Expand Up @@ -195,7 +194,7 @@ $ docker images

# Example
REPOSITORY TAG ID CREATED
node 8 1934b0b038d1 5 days ago
node 10 1934b0b038d1 5 days ago
<your username>/node-web-app latest d64d3505b0d2 1 minute ago
```

Expand Down
13 changes: 6 additions & 7 deletions locale/fa/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ touch Dockerfile
Open the `Dockerfile` in your favorite text editor

The first thing we need to do is define from what image we want to build from.
Here we will use the latest LTS (long term support) version `8` of `node`
Here we will use the latest LTS (long term support) version `10` of `node`
available from the [Docker Hub](https://hub.docker.com/):

```docker
FROM node:8
FROM node:10
```

Next we create a directory to hold the application code inside the image, this
Expand Down Expand Up @@ -134,17 +134,16 @@ EXPOSE 8080
```

Last but not least, define the command to run your app using `CMD` which defines
your runtime. Here we will use the basic `npm start` which will run
`node server.js` to start your server:
your runtime. Here we will use `node server.js` to start your server:

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

Your `Dockerfile` should now look like this:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -162,7 +161,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

## .dockerignore file
Expand Down
13 changes: 6 additions & 7 deletions locale/it/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ touch Dockerfile
Open the `Dockerfile` in your favorite text editor

The first thing we need to do is define from what image we want to build from.
Here we will use the latest LTS (long term support) version `8` of `node`
Here we will use the latest LTS (long term support) version `10` of `node`
available from the [Docker Hub](https://hub.docker.com/):

```docker
FROM node:8
FROM node:10
```

Next we create a directory to hold the application code inside the image, this
Expand Down Expand Up @@ -134,17 +134,16 @@ EXPOSE 8080
```

Last but not least, define the command to run your app using `CMD` which defines
your runtime. Here we will use the basic `npm start` which will run
`node server.js` to start your server:
your runtime. Here we will use `node server.js` to start your server:

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

Your `Dockerfile` should now look like this:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -162,7 +161,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

## .dockerignore file
Expand Down
23 changes: 11 additions & 12 deletions locale/ja/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ touch Dockerfile
Open the `Dockerfile` in your favorite text editor

The first thing we need to do is define from what image we want to build from.
Here we will use the latest LTS (long term support) version `8` of `node`
Here we will use the latest LTS (long term support) version `10` of `node`
available from the [Docker Hub](https://hub.docker.com/):

```docker
FROM node:8
FROM node:10
```

Next we create a directory to hold the application code inside the image, this
Expand Down Expand Up @@ -207,17 +207,16 @@ EXPOSE 8080
```

Last but not least, define the command to run your app using `CMD` which defines
your runtime. Here we will use the basic `npm start` which will run
`node server.js` to start your server:
your runtime. Here we will use `node server.js` to start your server:

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

Your `Dockerfile` should now look like this:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -235,7 +234,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

-->
Expand All @@ -251,10 +250,10 @@ touch Dockerfile

最初にしなければならないことは、どのイメージから構築したいかを定義することです。
ここでは[Docker Hub](https://hub.docker.com/)から入手できる
`node` の最新の LTS (long term support) バージョン `8` を使います。
`node` の最新の LTS (long term support) バージョン `10` を使います。

```docker
FROM node:8
FROM node:10
```

次に、イメージ内にアプリケーションコードを入れるディレクトリを作成します。
Expand Down Expand Up @@ -306,13 +305,13 @@ EXPOSE 8080
基本的な `npm start` を使います:

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

`Dockerfile` はこのようになっているはずです。

```docker
FROM node:8
FROM node:10

# アプリケーションディレクトリを作成する
WORKDIR /usr/src/app
Expand All @@ -330,7 +329,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

<!--
Expand Down
23 changes: 11 additions & 12 deletions locale/ko/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ touch Dockerfile
Open the `Dockerfile` in your favorite text editor

The first thing we need to do is define from what image we want to build from.
Here we will use the latest LTS (long term support) version `8` of `node`
Here we will use the latest LTS (long term support) version `10` of `node`
available from the [Docker Hub](https://hub.docker.com/):

```docker
FROM node:8
FROM node:10
```
-->

Expand All @@ -171,10 +171,10 @@ touch Dockerfile

가장 먼저 해야 할 것은 어떤 이미지를 사용해서 빌드할 것인지를 정의하는 것입니다. 여기서는
[Docker Hub](https://hub.docker.com/)에 있는
`node`의 최신 LTS(장기 지원) 버전인 `8`을 사용할 것입니다.
`node`의 최신 LTS(장기 지원) 버전인 `10`을 사용할 것입니다.

```docker
FROM node:8
FROM node:10
```

<!--
Expand Down Expand Up @@ -273,17 +273,16 @@ EXPOSE 8080

<!--
Last but not least, define the command to run your app using `CMD` which defines
your runtime. Here we will use the basic `npm start` which will run
`node server.js` to start your server:
your runtime. Here we will use `node server.js` to start your server:

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

Your `Dockerfile` should now look like this:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -301,21 +300,21 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```
-->

마지막으로 런타임을 정의하는 `CMD`로 앱을 실행하는 중요 명령어를 정의해야 합니다.
여기서는 서버를 구동하도록 `node server.js`을 실행하는 기본 `npm start`을 사용할 것입니다.

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

`Dockerfile`은 다음과 같아야 합니다.

```docker
FROM node:8
FROM node:10

# 앱 디렉터리 생성
WORKDIR /usr/src/app
Expand All @@ -333,7 +332,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

<!--
Expand Down
13 changes: 6 additions & 7 deletions locale/ru/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ touch Dockerfile
Open the `Dockerfile` in your favorite text editor

The first thing we need to do is define from what image we want to build from.
Here we will use the latest LTS (long term support) version `8` of `node`
Here we will use the latest LTS (long term support) version `10` of `node`
available from the [Docker Hub](https://hub.docker.com/):

```docker
FROM node:8
FROM node:10
```

Next we create a directory to hold the application code inside the image, this
Expand Down Expand Up @@ -136,17 +136,16 @@ EXPOSE 8080
```

Last but not least, define the command to run your app using `CMD` which defines
your runtime. Here we will use the basic `npm start` which will run
`node server.js` to start your server:
your runtime. Here we will use `node server.js` to start your server:

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

Your `Dockerfile` should now look like this:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -164,7 +163,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

## .dockerignore file
Expand Down
10 changes: 5 additions & 5 deletions locale/zh-cn/docs/guides/nodejs-docker-webapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ touch Dockerfile

用你最喜欢的文本编辑器打开这个 `Dockerfile`。

我们要做的第一件事是定义我们需要从哪个镜像进行构建。这里我们将使用最新的 LTS(长期服务器支持版),`Node` 的版本号为 `8`。你可以从 [Docker 站点](https://hub.docker.com/) 获取相关镜像:
我们要做的第一件事是定义我们需要从哪个镜像进行构建。这里我们将使用最新的 LTS(长期服务器支持版),`Node` 的版本号为 `10`。你可以从 [Docker 站点](https://hub.docker.com/) 获取相关镜像:

```docker
FROM node:8
FROM node:10
```

下一步在镜像中创建一个文件夹存放应用程序代码,这将是你的应用程序工作目录:
Expand Down Expand Up @@ -112,13 +112,13 @@ EXPOSE 8080
最后但同样重要的事是,使用定义运行时的 `CMD` 定义命令来运行应用程序。这里我们使用最简单的 `npm start` 命令,它将运行 `node server.js` 启动你的服务器:

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

你的 `Dockerfile` 现在看上去是这个样子:

```docker
FROM node:8
FROM node:10

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -136,7 +136,7 @@ RUN npm install
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD [ "node", "server.js" ]
```

## .dockerignore 文件
Expand Down