appsody / stacks

Appsody application stacks. This repo will be archived soon.
https://appsody.dev
Apache License 2.0
89 stars 121 forks source link

nodejs: Add 'build' and 'prune' lifecycle events #841

Closed djones6 closed 4 years ago

djones6 commented 4 years ago

Checklist:

Modifying an existing stack:

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.

Related Issues: