buildpacks icon indicating copy to clipboard operation
buildpacks copied to clipboard

Yarn caching?

Open richardmcsong opened this issue 2 years ago • 1 comments

Sorry if I'm missing something -- I only recently started looking into buildpacks to see if they would fit our usecase.

I can't figure out how yarn would cache dependencies with buildpacks. I'm using the most recent stable version of yarn (v3.2.1), and I've left all of the defaults (local .yarn/cache). With Dockerfiles, I can inline cache on a global cache folder.

For every dependency I have, I keep on getting can't be found in the cache and will be fetched from the remote registry.

I've tried the following:

  • enabling global cache (in hopes that the --cache-image will pick up on those files). I've also left it disabled.
  • I've tried yarn installing on host first. This caches the dependencies on my host filesystem, but I'd like to avoid this case, since we develop on mac machines, but run on linux. Zero-installs breaks my build since bcrypt seems to be OS specific: https://stackoverflow.com/questions/15809611/bcrypt-invalid-elf-header-when-running-node-app

If I understand correctly, it's because yarn install is run on the buildkit docker container, and therefore requires some way of storing the cache. I also can't find cache handling logic in pkg/nodejs/yarn.go.

richardmcsong avatar May 30 '22 11:05 richardmcsong

Upon further inspection, it looks like that yarn 1 has caching logic, but yarn 2 implies usage of pnp, which isn't necessarily true.

richardmcsong avatar May 30 '22 12:05 richardmcsong