You don't need to handle anything of that by yourself, just use Laravel Sail! It will setup your complete Dev-Environment including Nodejs. It's easy to install into existing Projects. https://laravel.com/docs/8.x/sail#executing-node-npm-commands
Deploying Laravel Mix using Docker?
I'm currently trying to move an existing Laravel app onto Docker containers using docker-compose. All good so far, except I'm stuck on how to run the npm install and npm run mix steps. I've got a node.js image and I think I should just have to mount the application root directory as a bind-mount, run the npm scripts, and then the built files should be dumped into the application directory on the host, thanks to the bind mount, right?
However, whatever I try, I don't seem to even get the node_modules directory on my host file system. I just get the "node js container exited with status code 0" message and nothing else seems to change.
Rather than waste time posting my Docker files and asking for critique, I guess there must be people who do this frequently, given the popularity of Laravel and of Docker. How do you manage this step? How do you run your Javascript build step using containers? What's the best practice?
Please or to participate in this conversation.