Whenever I run,
docker-compose run --rm npm run production
Laravel mix takes around 15 minutes to complete the build. I suspect this is due to inherent slowness of Docker Desktop for Windows - I say this because even my Laravel site is loading slowly in my browser when accessed over localhost.
In order to attempt to speed up my Docker Desktop, I have created the following .wslconfig
file in C:\Users<my_username>,
[wsl2]
memory=8GB
processors=2
I am definitely using WSL version 2. Please refer:
The following https://github.com/docker/for-win/issues/1936#issuecomment-380257581 was promising: I excluded my project files from my Norton Antivirus' "scannable" files, temporarily disabled my Antivirus.
After doing all of the above, I shutdown my WSL on my Windows by using wsl --shutdown
which automatically shutdown Docker Desktop. I then restarted Docker Desktop. But after all this, npm run production
is still frustratingly slow in my Docker Container.
I would be grateful to understand if I am missing something.
Here is my PC config:
I am using Windows 10 Home.
Here is the npm snippet from my docker-compose.yml file:
npm:
build:
context: ./dockerfiles
dockerfile: node.dockerfile
container_name: npm
volumes:
- ./src:/var/www/html
ports:
- 3008:3000
- 3009:3001
working_dir: /var/www/html
entrypoint: ['npm']
networks:
- laravel
And the contents of node.dockerfile:
FROM node:14.5.0-alpine
The site ( configured using a separate NGINX DOCKER container ) itself is slow to load, this is why I suspect that this is related to Memory size issue of Docker Desktop. But I am happy to accept counter arguments to my theory, probably this might be the result of a misconfigured npm Docker container on my local. But whatever it is, npm is taking hell lot of time to build my project (no matter what I do)!
FROM
line and you're bind-mounting everything that would run inside the container, would it be easier to just run Node directly on your host? Are you hitting the problems described in docker on wsl2 very slow?