mirror of https://github.com/docker/docs.git
Update build-images.md (#12843)
* Update build-images.md Small typos in the documentation, which may lead to confusion. * Inspiration from node.js docs Added documentation for why we copy `package*.json` before copying the whole directory. Checkout: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/#creating-a-dockerfile. The node.js docs has more optimized code too (using `npm ci` instead of `npm install`) which can be used here too. * Fixed review provided and removed some weird whitespaces
This commit is contained in:
parent
33576a4efb
commit
6531e8ef21
|
@ -3,7 +3,7 @@ title: "Build your Node image"
|
|||
keywords: containers, images, node.js, node, dockerfiles, node, coding, build, push, run
|
||||
description: Learn how to build your first Docker image by writing a Dockerfile
|
||||
redirect_from:
|
||||
- /get-started/nodejs/build-images/
|
||||
- /get-started/nodejs/build-images/
|
||||
---
|
||||
|
||||
{% include_relative nav.html selected="1" %}
|
||||
|
@ -40,12 +40,12 @@ Now, let’s add some code to handle our REST requests. We’ll use a mock serve
|
|||
Open this working directory in your IDE and add the following code into the `server.js` file.
|
||||
|
||||
```js
|
||||
const ronin = require( 'ronin-server' )
|
||||
const mocks = require( 'ronin-mocks' )
|
||||
const ronin = require('ronin-server')
|
||||
const mocks = require('ronin-mocks')
|
||||
|
||||
const server = ronin.server()
|
||||
|
||||
server.use( '/', mocks.server( server.Router(), false, true ) )
|
||||
server.use('/', mocks.server(server.Router(), false, true))
|
||||
server.start()
|
||||
```
|
||||
|
||||
|
@ -145,7 +145,8 @@ Before we can run `npm install`, we need to get our `package.json` and `package-
|
|||
COPY ["package.json", "package-lock.json*", "./"]
|
||||
```
|
||||
|
||||
Once we have our `package.json` files inside the image, we can use the `RUN` command to execute the command npm install. This works exactly the same as if we were running npm install locally on our machine, but this time these Node modules will be installed into the `node_modules` directory inside our image.
|
||||
Note that, rather than copying the entire working directory, we are only copying the package.json file. This allows us to take advantage of cached Docker layers.
|
||||
Once we have our files inside the image, we can use the `RUN` command to execute the command npm install. This works exactly the same as if we were running npm install locally on our machine, but this time these Node modules will be installed into the `node_modules` directory inside our image.
|
||||
|
||||
```dockerfile
|
||||
RUN npm install --production
|
||||
|
|
Loading…
Reference in New Issue