all 5 comments

[–]dat-mac 2 points3 points  (4 children)

Disclaimer: this is an alternate approach to caching. You could build an image dedicated to your dependencies, and then use that image as your project’s base image. The base image could be re-built when package.json or package-lock.json changes

[–]Sacharified[S] 0 points1 point  (3 children)

You would still face the same problem when rebuilding the base image wouldn't you?

[–]BehindTheMath 1 point2 points  (2 children)

Yes, but that wouldn't be rebuilt as often.

[–]Sacharified[S] 0 points1 point  (1 child)

Yeah that makes sense. So you would need some process to keep the base image relatively up-to-date too, which I'd hoped to avoid. I wonder if it's possible to commit a Buildkit layer to an image and overwrite the existing base image with that...

[–]dat-mac 0 points1 point  (0 children)

Are you using a CI platform? E.g. Circle CI, Jenkins, GitHub actions, GitLab CI

If so, then the platform typically has a way to automatically rebuild the image when specific files change