I’m trying to provision a project locally that’s using NodeJs with NPM.
npm install on my host machine (MacBook Pro Retina, 15-inch, Mid 2015) using
nvm with node version
added 2335 packages from 985 contributors and audited 916010 packages in 61.736s
When I run the same setup in Docker, the result is much slower. This is my
version: '3.4' services: node: image: node:10.19-alpine container_name: node volumes: - .:/app/ - npm-cache:/root/.npm working_dir: /app command: ["tail", "-f", "/dev/null"] volumes: npm-cache: external: false
Then I execute:
docker-compose up -d node; docker exec -t node npm install
And the result is:
added 2265 packages from 975 contributors and audited 916010 packages in 259.895s
(I’m assuming the number of resulting packages is different due to a different platform).
I thought the speedy installation was achieved by having a local cache (that’s why there is an extra volume for caching in the docker-compose) but then I ran:
$ npm cache clean --force && rm -rf ~/.npm && rm -rf node_modules
and the result for installation on the host machine is still consistently ~60 seconds.
When it comes to resources allocated to the Docker VM, it shouldn’t be a problem, here’s my Docker VM configuration:
I don’t know where else to look, any help would be greatly appreciated.