简体   繁体   English

忽略Docker卷中的每个`node_modules`

[英]Ignoring every `node_modules` in a docker volume

I am trying to ignore every node_modules in every workspaces / sub folders. 我试图忽略每个工作区/子文件夹中的每个node_modules

The fact is : it is impossible to (really) ignore a folder by its name in a volume. 事实是:不可能(真的)忽略卷中文件夹的名称。

So there was this trick : 因此,有一个技巧:

volumes:
  - ./:/app
  - /app/node_modules

It works well for apps that have one single node_modules . 它仅适用于具有单个node_modules应用程序。 But what if there is multiple one like in the bellow directory tree ? 但是,如果在波纹管目录树中有多个类似的文件怎么办?

project
|   node_modules/
|   docker-compose.yml
|   Dockerfile
|
└─── workspaces/
|   └─── client/
|       |   node_modules/
|   |
|   └─── server/
|       |   node_modules/

Do I need really need to mount every node_modules as a volume in my docker-compose.yml ? 我真的需要将每个node_modules作为卷挂载到node_modules docker-compose.yml吗?

volumes:
  - ./:/app
  - /app/node_modules
  - /app/workspaces/client/node_modules
  - /app/workspaces/server/node_modules

Or is there another better way ? 还是还有另一种更好的方法?

rewrite as "*node_modules" 重写为“ * node_modules”
hopefully it helps 希望它会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM