I'm using docker-compose
to orchestrate containers for multiple separate projects. Each of these projects has their own set of containers and do not relate to other projects.
For example:
/my-projects/project-1/docker-compose.yml
/my-projects/project-2/docker-compose.yml
/my-projects/project-3/docker-compose.yml
These projects are, however, similar in that they are all PHP projects and use webpack for front-end assets, thus share the same package managers: composer
and yarn
.
I was wondering, in the interest of performance, if it would be possible to mount a shared volume outside the directory root of all the projects for package manager caches?
For example:
/my-projects/caches/composer
/my-projects/caches/npm
/my-projects/project-1/docker-compose.yml
/my-projects/project-2/docker-compose.yml
/my-projects/project-3/docker-compose.yml
Where /my-projects/caches/composer
and /my-projects/caches/npm
get mounted inside the relevant containers within each project. In case it's not clear, only one project would be spun up at a time.
At the moment, if two projects share the same deps then each downloads and caches it individually. A more performant (in terms of build times) would be to mount a common volume and point the package manager's caches there so that when "Project A" downloads an update to a dip, "Project B" can load it from cache.