Comments (3)
@bmaupin, thanks for your suggestion.
Would it work better to use npm install --production
then?
from loopback-next.
@bmaupin, thanks for your suggestion. Would it work better to use
npm install --production
then?
I think my original wording in the issue description was a bit misleading so I tried to update it. The short version is that npm ci --only=production
is ideal for the final built image but will only work with some additional changes to the Dockerfile.
As far as I understand, npm install
should only be used for local development. When building the application for deployment (especially for production), npm ci
should be used. It ensures that the dependencies are installed cleanly and will also result in reproducible builds; this isn't the case with npm install
because it may update packages in package-lock.json unless package versions are explicitly pinned.
In addition, modifying the existing Dockerfile (I think this is it? and replacing npm install
with npm install --production
will break the build, because the devDependencies are required for the npm run build
command to work.
I had to solve this with a multi-stage build in my example above, where the first stage uses npm ci
to install all dependencies (including devDependencies) and run the build, then in the second stage, the built JavaScript files are copied and npm ci --only=production
is run to exclude devDependencies from the final container image.
from loopback-next.
I was working with a Loopback 4 application today and I noticed another issue with the generated Dockerfile: it does a build every time the container image is run. This of course is slower, and it also presents more potential points of failure at runtime.
The Dockerfile I proposed already remediates this, but I added an extra note about this in the issue description.
from loopback-next.
Related Issues (20)
- Rest nested include
- How to integrate passport authentication without express web app?
- [@loopback/sequelize] Regression in query behavior when undefined values passed to "where" filter
- Error creating todo-list application HOT 1
- [@loopback/sequelize] Boolean values from Loopback "where" filter are not serialized correctly
- [@loopback/sequelize] Scope setting on Loopback Model is ignored by Sequelize extension
- @loopback/rest - v13.1.3 request validation fails
- [@loopback/sequelize] Test sandbox directory is included in the published NPM package
- [@loopback/sequelize] Typescript error when using the "required" property with Sequelize HOT 2
- Polymorphic relations broke SQL Transactions HOT 5
- Error when running `npm run tsdocs`
- @loopback/repository 6.1.4 broke hasManyThrough relations HOT 4
- [@loopback/sequelize] contains & match (extendedOperators) are not working HOT 1
- [@loopback/sequelize] SQL select error if an empty string "order" is passed to SequelizeRepository find / findOne methods
- Options param in SequelizeRepository create methods issue HOT 1
- ESLint: naming convention errors on certain third-party imports
- @loopback/sequelize:modify the regular expression to match a select query with parentheses
- [BOOT] Not possible to import ESM project files HOT 2
- [@loopback/sequelize] Unable to order by associations using "order" filter
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 loopback-next.