I am not very familiar working with docker, this is part of a large enterprise app that's moving the dev environment to docker.
Right now, yarn install
outside of docker takes about 10 minutes to complete, this is mainly done in Linking Dependencies...
step, as there are over 30k objects to link I guess. After the first yarn install
, it takes only 1 second to complete. If I change one dependency, it takes about 10 seconds to complete. So it's much faster than 10 minutes!
But inside of docker it takes about 5-10 minutes every time, no matter if dependencies change or not.
Any ideas why this is happening?
We use docker-compose and have several disparate processes, one of which is a node server. The node server runs yarn install whenever the package.json changes, but this is rather frequent (it gets updated several times daily). So yarn install runs several times a day. Ideally this would be as fast as running it outside of docker, but I'm not sure where to begin looking. Is there a setting or something that is removing the yarn cache on every docker-compose restart node
, or what?
We have basically this in docker-compose.yml
:
services:
...
node:
image: myimage:latest
...
volumes:
- ./:/app:cached
- ./node_modules_docker:/app/node_modules:cached
working_dir: /app
...
...
It seems that the latest "Docker Desktop for Mac Edge" version somehow optimizes how the files are shared.
Using the latest version (2.5.3 today): https://docs.docker.com/docker-for-mac/edge-release-notes/
Now, running yarn install
in docker seems to be as fast as running it on my mac.
Hope it'll help someone.
EDIT 2021/02/26 :
I kept docker up to date (3.x) and somehow I experimented very slow yarn install again.
Using Docker 2.5.4 (edge) makes things fast again : https://github.com/docker/docker.github.io/blob/master/docker-for-mac/edge-release-notes.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With