exaco / laravel-octane-dockerfile

Production-ready Dockerfile for Laravel Octane (FrankenPHP, Swoole, RoadRunner) powered web services and microservices. Done right.
MIT License
590 stars 89 forks source link

Add support for vite builds #41

Closed sloan58 closed 1 year ago

smortexa commented 1 year ago

The Docker image build fails with this error:

Could not read package.json: Error: ENOENT: no such file or directory, open '/var/www/html/package.json'
sloan58 commented 1 year ago

After adding NODE_ENV=production, mine fails because it's not able to find vite, though I don't get an error about package.json. Do you have a package.json in your Laravel project?

This works for me:

tbh, I don't set NODE_ENV=production when building. Since the intermediate build is not included in the final image and we get the prod build in public, is it necessary to include those statements?

smortexa commented 1 year ago

Thank you for your assistance! I have attempted several times to run the code on my machine and via GitHub actions, but I kept encountering the same error. I want to clarify that I have already made sure that the package.json file exists. It's possible that you are not experiencing this error because in the particular commit you referenced, you are checking for the existence of package.json before running the npm commands.

Nevertheless, I will give it another try and see if I can resolve the issue.

As a best practice for Dockerizing Node apps, I had previously set NODE_ENV=production, but I now realize that it may not be necessary in this case since the bundlers are usually smart enough to handle the build process efficiently.

sloan58 commented 1 year ago

np! Glad to try and help. This package is awesome. Yes, I was not checking for package.json in my PR, which should be done. Assuming everyone has one isn't safe, even if it comes standard today with a laravel new.

I can adjust my PR and resubmit with the check for package.json and also NODE_ENV removed if you'd like?

smortexa commented 1 year ago

I appreciate it. Feel free to adjust your PR and resubmit it with the necessary changes.