Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying prestart and poststart lifecycle scripts #36

Open
achrinza opened this issue Nov 11, 2024 · 0 comments
Open

Modifying prestart and poststart lifecycle scripts #36

achrinza opened this issue Nov 11, 2024 · 0 comments

Comments

@achrinza
Copy link

achrinza commented Nov 11, 2024

Describe the Enhancement

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

  1. Provide flags to disable prestart and poststart scripts through BP_NPM_DISABLE_PRESTART_SCRIPT and BP_NPM_DISABLE_POSTSTART_SCRIPT

or

  1. 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.

@achrinza achrinza changed the title Disabling prestart and poststart lifecycle scripts Modifying prestart and poststart lifecycle scripts Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant