VlerrieBR's avatar

Docker Compose + Laravel Inertia + Vite is extremely slow

Now I know docker-compose can be slower than the sail route but our team prefers it. This is a new project that I'm doing the setup for.

When building assets for production using vite the responses are reasonably quick, and when running 'npm run dev' it slows down a bit (still okay) but then when I make changes to any vue files, I'm waiting more than a minute for a response.

Is there a way for me to speed this up as developing like this is going to be extremely cumbersome, I've also tried 'vite --watch' but that does not seem to pick up any changes.

Laravel: 10.44.0

Vite: 5.1.1

Docker-image: php:8.2

Let me know if you need more info.

0 likes
9 replies
gych's avatar

Are you the only one in the team having this issue or are other team members also experiencing it?

VlerrieBR's avatar

@gych I'm still in the initial setup stages so other team members have not worked on it yet, I can check on that in the morning, will get back to you.

1 like
VlerrieBR's avatar

@gych Tested on 2 other machines and they performed even worse. With just the production build about 3-5 secs to load login page and with npm run dev over 3 minutes to load login page.

VlerrieBR's avatar

I've resorted to running npm on my windows instead of the container. That sorted the issue. Looks like Vite and docker WSL2 don't work well together?

VlerrieBR's avatar

@gych I think when going the docker-compose route instead of sail is when the issues start? Either that or something in my docker compose containers is not set up correctly.

baumgars's avatar

@VlerrieBR i noticed the same. I see in Laracon videos the Laravel team, they use Apple computers so no need to go into a virtual machine like WSL 2 and deal with all kinds of problems.

max-power7's avatar

If you are using Windows, it is because of WSL2 is slow, if you install your code in Windows folder. See my response her:

have a very strong PC, and after installing Laravel on Docker with Sail I have experienced the response time on frontpage at 740 ms. This is a lot. The solution I used is this:

Store your project in the Linux filesystem of WSL 2

Again, since this issue occurs when WSL 2 tries to access the mount points of the Windows filesystem under /mnt, you could choose to store your project onto the Linux filesystem of WSL 2 instead

What I did I went to my home folder "~" or "/home/" and created a folder "code" and installed Laravel using this command for installing with curl (can not provide link). And followed all the steps to complete installation from laravel installation guide.

As a result, it loads with 20 ms !!! So yeah, it works if reinstalling things completely, but if you want to move your project, you will need to do some extra job.

By the way, in windows your path to this home folder is "wsl.localhost\Ubuntu\home\code\example-app". Open any window in Windows and insert in path "wsl.localhost\Ubuntu\home". From there you can navigate. And you can use the same path to open your project in VSCode or any other editor!

Thanks for your help guys!!! So happy I got it fixed. Idea of waiting 1 second every reload was killing me!

Solution is to install your project in your Linux subsystem folder and not in "mnt".

Good luck!

2 likes
baumgars's avatar

@max-power7 "Store your project in the Linux filesystem of WSL 2"

I use PHPStorm on Windows, so how would i access the project in WSL2 ?

Please or to participate in this conversation.