You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, only the start script can be overridden with the BP_NPM_START_SCRIPT build-time environment variable. However, prestart and poststart scripts are still parsed by libnodejs, and executed by downstream buildpacks such as npm-start.
Possible Solution
Provide flags to disable prestart and poststart scripts through BP_NPM_DISABLE_PRESTART_SCRIPT and BP_NPM_DISABLE_POSTSTART_SCRIPT
or
Allow pointing to custom prestart and poststart scripts with BP_NPM_PRESTART_SCRIPT and BP_NPM_POSTSTART_SCRIPT, and disabling of them with a blank string
(1) makes more sense IMO as I can't foresee the utility of separate lifecycle scripts if one were to use a custom start script anyways. However I also can't rationalise the current default behaviour of parsing prestart and poststart when Paketo already has a separate build stage, hence I might be missing a use-case.
(2) would mostly be a copy-and-paste of BP_NPM_START_SCRIPT logic.
Motivation
The convention in some projects is for the prestart script to call build scripts. This gives developers a short command to quickly spin up a production-like instance without having to manually run a separate build step. When deploying to production, npm start --ignore-script can be used to skip the build scripts.
Also as a developer, pointing to a custom start script using BP_NPM_START_SCRIPT implies that the script is not appropriate for the intended deployment. Lifecycle scripts such as prestart and poststart would inherit the same concerns of the base start script as npm run would implicitly execute them by default.
Hence there's a weird disconnect when configuring Paketo to use a custom start script, but prestart and/or poststart are still set in package.json and hence are also executed by Paketo.
The text was updated successfully, but these errors were encountered:
achrinza
changed the title
Disabling prestart and poststart lifecycle scripts
Modifying prestart and poststart lifecycle scripts
Nov 11, 2024
Describe the Enhancement
Currently, only the
start
script can be overridden with theBP_NPM_START_SCRIPT
build-time environment variable. However,prestart
andpoststart
scripts are still parsed bylibnodejs
, and executed by downstream buildpacks such asnpm-start
.Possible Solution
prestart
andpoststart
scripts throughBP_NPM_DISABLE_PRESTART_SCRIPT
andBP_NPM_DISABLE_POSTSTART_SCRIPT
or
prestart
andpoststart
scripts withBP_NPM_PRESTART_SCRIPT
andBP_NPM_POSTSTART_SCRIPT
, and disabling of them with a blank string(1) makes more sense IMO as I can't foresee the utility of separate lifecycle scripts if one were to use a custom
start
script anyways. However I also can't rationalise the current default behaviour of parsingprestart
andpoststart
when Paketo already has a separate build stage, hence I might be missing a use-case.(2) would mostly be a copy-and-paste of
BP_NPM_START_SCRIPT
logic.Motivation
The convention in some projects is for the
prestart
script to call build scripts. This gives developers a short command to quickly spin up a production-like instance without having to manually run a separate build step. When deploying to production,npm start --ignore-script
can be used to skip the build scripts.Also as a developer, pointing to a custom
start
script usingBP_NPM_START_SCRIPT
implies that the script is not appropriate for the intended deployment. Lifecycle scripts such asprestart
andpoststart
would inherit the same concerns of the basestart
script asnpm run
would implicitly execute them by default.Hence there's a weird disconnect when configuring Paketo to use a custom
start
script, butprestart
and/orpoststart
are still set inpackage.json
and hence are also executed by Paketo.The text was updated successfully, but these errors were encountered: