-
Notifications
You must be signed in to change notification settings - Fork 17
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
Symlink node_modules/.cache to tempdir #661
Symlink node_modules/.cache to tempdir #661
Conversation
@paketo-buildpacks/nodejs-maintainers Before I polish the pr (e.g. adding tests), could someone have a look if this is a valid way to go? At least it works :) |
d467af4
to
aad42ad
Compare
@paketo-buildpacks/nodejs-maintainers Could someone have a look? |
41387e6
to
3367c6c
Compare
3367c6c
to
a3b4657
Compare
@paketo-buildpacks/nodejs-maintainers Could you provide some feedback? One specific question: Why are ALL integration tests run with this ubi builder from paketocommunity? This forces every test to use the extension, right? Doesn't feel right that there is no test without extension anymore tbh. |
a00f64a
to
329db12
Compare
I don't think this is the case, you can see that the integration tests are run twice. Once with jammy and once with ubi. Those with ubi use the extenstion and those with jammy don't @github-actions |
From my understanding, that is only partially correct. All tests have to use the extension in order to also run with the ubi builder, right? Like here Tbh, I do not really now what this The second point, is it really worth/needed to run all tests with |
329db12
to
05775c3
Compare
The ubi extension is added conditionally npm-install/integration/init_test.go Lines 90 to 94 in c2719ba
|
05775c3
to
53a062a
Compare
53a062a
to
27cd847
Compare
I bit of info I think on the cache option - https://docs.npmjs.com/cli/v10/using-npm/config#cache, not much. Would be interesting to see if can be set in .npmrc |
Ok so the cache option I mentioned in the last post seems to be unrelated. There is a cache option for eslint which is Unfortunately some of the dependencies seem to set that directly:
After some googling, I also found this package which seems to be widely used for finding the right place to write cache files - https://www.npmjs.com/package/find-cache-dir. It seems to use node_modules/.cache by default and also has an environment variable that can be used to override but I don't think that helps us with the modules that specify the cache location as shown above. |
I tried chaning the instances I showed above manually to /workspace, but none of those were the cause. Looking through other packages in node_modules results in find a bunch more places in bable, webpack etc that default to using the node_modules/.cache as a default location. Sooo, I've not convinced myself that the use of node_modules/.cache as a default is widespread enough that we should ensure it is writable by since its referenced in https://www.npmjs.com/package/find-cache-dir but also because it seems to be hard coded into packages like webpack and babel. @c0d1ngm0nk3y my only remaining question is if there is a risk that by removing the cache we might slow down startup of some applications because they benefit from data in the cache created during the build phase? If that might be the case then we might want an environment variable that can be used to turn the new behaviour off? |
I cannot rule this out completely. What would you call this environment variable? Something like Update: I would probably lean to |
I agree with letting the default be false as I hope there will be no issues but think having an escape hatch if there are is a good idead. I'm good with In terms of |
Not quite. Let's have you have two modules
You could not use BUT
So I will go on with your suggestion. |
27cd847
to
d2ee774
Compare
@mhdawson Is this the kind of use case you had in mind? |
@c0d1ngm0nk3y that does look like an example where not maintaining the cache could lead to slowdowns. |
Just to add on
Agree with your points of it not being a blocking concern. Also regressing existing applications is not a concern as there cannot be any working ones (since a would crash/not work). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@c0d1ngm0nk3y I'm ready to land but it tells me that the brach is out of date with the base and is not giving me the option to rebase in the UI. Could you rebase and then I'll land once the tests complete? Thanks for all of your work, explanation and tweaks along the way on this. |
Co-authored-by: Ralf Pannemans <[email protected]>
Co-authored-by: Ralf Pannemans <[email protected]>
d2ee774
to
79a5051
Compare
Fixes paketo-buildpacks/builder-jammy-base#375
Summary
The folder
node_modules/.cache
is written during runtime (e.g. byeslint
) this does not workjammy-builder
sincerun
undbuild
user are differentread-only
file-systemsSo this pr always creates the
.cache
folder as a symlink to the tempdir and the helper will create the needed dir for the link to be valid.Use Cases
As brought up in paketo-buildpacks/builder-jammy-base#375 already a very simple
react
app will not be able to be built with buildpacks since it containseslint
.Details
Note: The pr looks larger than it actually is. Most of the changes come from the
integration
folder where a simplereact
was added.After creating the
mode_modules
, the.cache
folder is removed and a symlink to/tmp/node_modules_cache
is added instead. This makes sure that the run user has the permission to add files in that directory. Since the build and the run user have different uids per default, this was not the case before.In addition
/tmp/node_modules_cache
has to be created at launch time since the symlink would be broken otherwise. For this, the existing helpersetup_symlinks
also creates this folder.Checklist