Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for vite builds #41

Merged
merged 3 commits into from
Sep 17, 2023
Merged

Add support for vite builds #41

merged 3 commits into from
Sep 17, 2023

Conversation

sloan58
Copy link
Contributor

@sloan58 sloan58 commented Sep 16, 2023

No description provided.

@smortexa smortexa merged commit 74f1b02 into exaco:main Sep 17, 2023
4 checks passed
smortexa added a commit that referenced this pull request Sep 17, 2023
@smortexa
Copy link
Member

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
Copy link
Contributor Author

sloan58 commented Sep 18, 2023

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:

  • git clone https://github.com/exaco/laravel-octane-dockerfile.git
  • cd laravel-octane-dockerfile.git
  • git checkout 74f1b02
  • (Remove the two NODE_ENV=production statements from the frontend build)
  • cd ../
  • laravel new test-app
  • cd test-app
  • cp -r ../laravel-octane-dockerfile/Dockerfile ../laravel-octane-dockerfile/deployment ./
  • docker build -t test-exaco . --no-cache

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
Copy link
Member

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
Copy link
Contributor Author

sloan58 commented Sep 19, 2023

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants