I added npm build and npm prune steps to the build process for the production image, to provide a point of customization in cases where the project needs to perform build actions (such as running the Angular or Typescript compiler).
The 'prune' step is required to remove any development dependencies, and/or perform any cleanup of artifacts generated during the build, which would otherwise bloat the final image.
Although there is an npm prune command, it does not behave the same way as install, test etc in that it does not invoke any scripts in package.json (none of prune, preprune, postprune are run). The only way to run a script called prune is to run npm run prune (which is what I've gone for). It is run with --production so that the user's script can invoke npm prune (possibly in addition to other actions), and this will have the effect of running npm prune --production, which removes any development-only dependencies.
Update: I added libssl1.1 and ca-certificates. This is required in order for the service to connect to others over https (with certificate verification), which I feel is a common enough requirement to be part of the base stack.
Checklist:
[x] Read the Code of Conduct and Contributing Guidelines.
[x] Followed the commit message guidelines.
[x] Stack adheres to Appsody stack structure.
Modifying an existing stack:
stack.yaml
I added
npm build
andnpm prune
steps to the build process for the production image, to provide a point of customization in cases where the project needs to perform build actions (such as running the Angular or Typescript compiler).The 'prune' step is required to remove any development dependencies, and/or perform any cleanup of artifacts generated during the build, which would otherwise bloat the final image.
Although there is an
npm prune
command, it does not behave the same way asinstall
,test
etc in that it does not invoke any scripts in package.json (none ofprune
,preprune
,postprune
are run). The only way to run a script calledprune
is to runnpm run prune
(which is what I've gone for). It is run with--production
so that the user's script can invokenpm prune
(possibly in addition to other actions), and this will have the effect of runningnpm prune --production
, which removes any development-only dependencies.Update: I added libssl1.1 and ca-certificates. This is required in order for the service to connect to others over https (with certificate verification), which I feel is a common enough requirement to be part of the base stack.
Related Issues: