Just starting to look into switching from yarn v1 to pnpm and using it in my local docker environment. I see a lot of examples on using pnpm with docker for the final production build, but am having trouble figuring out the best way to do it for local development.<p>I usually have a docker-compose.yml file like this<p><pre><code> ---
services:
node:
build:
context: .
volumes:
- ".:/app"
...
</code></pre>
where I bind mount my source code into the container and whenever I need to interact with the package manager, I would shell into the container and run `yarn add/build/etc...`<p>When doing this with pnpm, I notice that a `pnpm install` creates the `.pnpm-store` directory in `/app`, because of the bind mount, I see the directory in my source folder. I understand this is because of the limitations of how you can't hardlink across filesystems. I can easily gitignore it but I don't really see other people doing this.<p>Also, with this setup it seems like I'm not getting the benefit of pnpm's global store since every project would have its own local "global" store.
This consideration ins't really unique to pnpm but manifest in different ways across the package managers.<p>Basically you have a choice between sharing or isolating state, specifically package cache, between containers.<p>If you go full-on isolation, indeed the performance benefits of pnp go away and you'll redundantly pull down and install packages for every container. Here you might look into running a local registry (like Nexus or verdaccio) to push the cache there, and maybe disabling pnp alltogether.<p>If you go full-on-sharing, you might consider why you're even using Docker for development in the first place and not just nvm?<p>You have varying options in-between of course, like a per-project cache (so you still share between a directory tree but not machine-wide).<p>You'd do this by also mounting the appropriate path inside the home-dir of the container.<p>> I can easily gitignore it but I don't really see other people doing this.<p>Don't let the cargo-cult blind your own judgement on what best-practice mean for your project. And try refer to primary sources first, rather than third-party examples and random forums, in the future <a href="https://github.com/orgs/pnpm/discussions/6936">https://github.com/orgs/pnpm/discussions/6936</a> :)