TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How are you working with pnpm and local development with Docker?

1 pointsby btiover 1 year ago
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: - &quot;.:&#x2F;app&quot; ... </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&#x2F;build&#x2F;etc...`<p>When doing this with pnpm, I notice that a `pnpm install` creates the `.pnpm-store` directory in `&#x2F;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&#x27;t hardlink across filesystems. I can easily gitignore it but I don&#x27;t really see other people doing this.<p>Also, with this setup it seems like I&#x27;m not getting the benefit of pnpm&#x27;s global store since every project would have its own local &quot;global&quot; store.

1 comment

3npover 1 year ago
This consideration ins&#x27;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&#x27;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&#x27;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&#x27;d do this by also mounting the appropriate path inside the home-dir of the container.<p>&gt; I can easily gitignore it but I don&#x27;t really see other people doing this.<p>Don&#x27;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:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;pnpm&#x2F;discussions&#x2F;6936">https:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;pnpm&#x2F;discussions&#x2F;6936</a> :)