Commit fc90254 1 parent 35dc319 commit fc90254 Copy full SHA for fc90254
File tree 1 file changed +15
-0
lines changed
docs/tutorial/image-building-best-practices
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,21 @@ a change to the `package.json`. Make sense?
79
79
CMD [" node" , " /app/src/index.js" ]
80
80
` ` `
81
81
82
+ 1. Create a file named ` .dockerignore` in the same folder as the Dockerfile with the following contents.
83
+
84
+ ` ` ` ignore
85
+ node_modules
86
+ ` ` `
87
+
88
+ ` .dockerignore` files are an easy way to selectively copy only image relevant files.
89
+ You can read more about this
90
+ [here](https://docs.docker.com/engine/reference/builder/# dockerignore-file).
91
+ In this case, the ` node_modules` folder should be omitted in the second ` COPY` step because otherwise,
92
+ it would possibly overwrite files which were created by the command in the ` RUN` step.
93
+ For further details on why this is recommended for Node.js applications and other best practices,
94
+ have a look at their guide on
95
+ [Dockerizing a Node.js web app](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/).
96
+
82
97
1. Build a new image using ` docker build` .
83
98
84
99
` ` ` bash
You can’t perform that action at this time.
0 commit comments