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
|
@ -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