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

Rebuild with cached dependencies #393

Conversation

pbusko
Copy link
Contributor

@pbusko pbusko commented Aug 15, 2022

Summary

As reported in the #375, if an app has only package-lock.json and no node_modules folder, after the rebuild the node_modules symlink from the workspace will point to non-existent build layer, instead of launch layer. Also the launch layer was not cached, which resulted in missing node_modules at all.

Another issue which is fixed in scope of that PR, is that if the BP_NODE_PROJECT_PATH is set, the setup-symlinks would fail, since there's no symlink in the working directory. Fixed by exposing project path as a launch environment variable NODE_PROJECT_PATH

Potentially contains a fix for #342

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

Copy link
Member

@ryanmoran ryanmoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me if we can just make the suggested change to remove the cache flag from the launch layer.

build.go Outdated
if err != nil {
return packit.BuildResult{}, err
}
}
}

layer.Cache = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to set the cache flag on a launch layer. In this case, I believe the issue is that we've moved the layer.ExecD assignment outside of the if run conditional block which means it gets set on every run. Then, without the cache flag set, the exec.d binary getting written to the layer wipes out the previous contents. If you move the layer.ExecD setting back to its original location, then you can remove this flag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanmoran Thanks for the review. Are you sure about the original location, though? Originally, it was located at launch>run>build, but with that some caching test (vendored) fail. I moved it to launch>run and the test succeeds and I removed the layer.Cache=true. WDYT?

@c0d1ngm0nk3y c0d1ngm0nk3y force-pushed the rebuild-with-cached-dependencies branch 2 times, most recently from c4027fc to ce495f3 Compare August 23, 2022 13:18
- Introducing NODE_PROJECT_PATH to create correct symlinks at launch time

Co-authored-by: Philipp Stehle <philipp.stehle@sap.com>
Co-authored-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
@modulo11 modulo11 force-pushed the rebuild-with-cached-dependencies branch from ce495f3 to 0c6e911 Compare August 25, 2022 08:01
@pbusko pbusko requested review from ryanmoran and removed request for thitch97 August 25, 2022 12:39
@ryanmoran ryanmoran added the semver:patch A change requiring a patch version bump label Aug 26, 2022
@ryanmoran ryanmoran merged commit 4572350 into paketo-buildpacks:main Aug 26, 2022
@phil9909 phil9909 deleted the rebuild-with-cached-dependencies branch August 30, 2022 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants