Page MenuHomePhabricator

[tbs][builder] Inject nodejs buildpack
Closed, ResolvedPublic

Description

Until we can implement proper multi-buildpack support, injecting the nodejs buildpack before the primary application language buildpack (but after the apt buildpack, if there is one) would enable applications with statically generated frontend assets at buildtime. This could possibly be generalized to injecting any of the builder-supported buildpacks.

Details

TitleReferenceAuthorSource BranchDest Branch
builds-builder: bump to 0.0.76-20231012133802-65e5029crepos/cloud/toolforge/toolforge-deploy!116sstefanovabump_builds-buildermain
inject-buildpacks: inject nodejs buildpackrepos/cloud/toolforge/builds-builder!15sstefanovaslavina/inject-nodejsmain
Customize query in GitLab

Event Timeline

Slst2020 renamed this task from Inject nodejs buildpack to [tbs][builder] Inject nodejs buildpack.Sep 18 2023, 1:12 PM
Slst2020 created this task.
dcaro changed the task status from Open to Stalled.Sep 26 2023, 1:31 PM
Slst2020 changed the task status from Stalled to In Progress.Sep 28 2023, 8:54 AM

I created a dummy Vue + Flask project that uses nodejs to build the Vue static assets at buildtime. This generates a ./dist folder from which the assets are served by the Flask application.

  • It injects the nodejs buildpack by prepending it to group.toml
  • The Python buildpack is selected when the detect lifecycle step is run
  • The execution order is nodejs first, then python
  • The nodejs buildpack takes care of installing npm, i.e. it's not necessary to specify the npm buildpack separately.
  • The nodejs buildpack executes the build script specified in package.json
  • The image builds and runs as expected when built with either pack or the tekton pipeline

The project repo is here: https://github.com/blancadesal/flask-vue I will migrate it to Gitlab when finished.

I've tested with both, and in this particular case, it doesn't seem to matter in which order the nodejs and python buildpacks are executed. However, the Heroku docs say...

The buildpack for the primary language of your app should always be the last buildpack in the list. This ensures that defaults for that primary language are applied instead of those for another language, and allows Heroku to correctly detect the primary language of your app.

So just to be cautious, we will be injecting the nodejs buildpack before other language packs. In the future, it may become possible to specify the ordering by file, the CLI, or both.