Comments (4)
Hello @nodejsdeveloperskh,
The new Dockerfile is now on the master branch & everything is working fine - thanks for the contribution.
from nestjs-template.
Hi @nodejsdeveloperskh 👋
The major difference between the 2 calls to npm ci
is located in the NODE_ENV
environment variable. This variable tells NPM if the command is launched in a production environment or not. In the first Docker stage (the build stage) our NODE_ENV
variable is set to build
(it could also be set to develop or testing) and the npm ci
will therefore install all dependencies - even the development dependencies. This is essentiel because we need to build the TypeScript code and require the presence of development dependencies.
In the second stage (which will be our final Docker image) we have moved the Node.js code in the image and require only the production dependencies. We therefore set the NODE_ENV
to production
and npm ci
will only install the production dependencies. This ensures that we only have the required Node.js components in the final Docker image.
I hope this answers your question 👍
from nestjs-template.
@Saluki Thanks for the reply. Yup, I am inattention to the details. but I think you could do it simpler by npm prune --production
in the second stage. after that you could copy the node_modules
like the dist
directory. unless you use the different base images in the stages.
from nestjs-template.
This is indeed an excellent proposal, I didn't know npm prune
could target production dependencies only. I will reopen the issue since it may be an interesting Docker build optimization.
from nestjs-template.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-template.