coolify icon indicating copy to clipboard operation
coolify copied to clipboard

[Bug]: Laravel 9 Yarn Command Issue

Open wildangunawan opened this issue 3 years ago • 13 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Example public repository

No response

Description

Laravel, starting from version 9, no longer using Laravel Mix to compile frontend things. Laravel moved to Vite for this.

Therefore, yarn production during image building won't work since they're no longer have that command. image

To solve this issue, I think it's simply to change this line from yarn production to yarn build. But that will create new issue for devs that haven't moved to Vite yet. Probably adding configuration for user to select either Vite (yarn build instead) or Mix (yarn production)?

For other developers that run to this issue

This issue can be solved easily by adding "production" script in your package.json file. image

Steps To Reproduce

  1. Create a new Laravel version 9 application
  2. Run in Coolify
  3. Failing at step 5/5

Version

3.12.1

wildangunawan avatar Dec 14 '22 09:12 wildangunawan

Also I think it's not only that. Since they moved from Webpack+Mix to Vite, the config file also changed.

image

from this should be changed to COPY *.json *.config.js /app/ (or something like that) as well.

wildangunawan avatar Dec 14 '22 09:12 wildangunawan

I'm having a similar problem deploying Laravel (both with and without a frontend). Here is the error message:

[00:17:00.908] #9 20.09 yarn run v1.22.19
[00:17:00.919] #9 20.12 $ vite build
[00:17:01.192] #9 20.44 vite v3.2.5 building for production...
[00:17:01.328] #9 20.58 ✓ 0 modules transformed.
[00:17:01.414] #9 20.58 Could not resolve entry module (index.html).
[00:17:01.445] #9 20.59 error during build:
[00:17:01.458] #9 20.59 Error: Could not resolve entry module (index.html).
[00:17:01.468] #9 20.59     at error (file:///app/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
[00:17:01.486] #9 20.59     at ModuleLoader.loadEntryModule (file:///app/node_modules/rollup/dist/es/shared/rollup.js:22175:20)
[00:17:01.492] #9 20.59     at async Promise.all (index 0)
[00:17:01.498] #9 20.63 error Command failed with exit code 1.
[00:17:01.504] #9 20.63 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[00:17:01.511] #9 ERROR: executor failed running [/bin/sh -c yarn install && yarn production]: exit code: 1
[00:17:01.556] ------
[00:17:01.569] > [5/5] RUN yarn install && yarn production:
[00:17:01.582] ------
[00:17:01.598] executor failed running [/bin/sh -c yarn install && yarn production]: exit code: 1

MichaelNZ85 avatar Dec 14 '22 10:12 MichaelNZ85

Yep, that's, I suspect, because the Dockerfile didn't copy the config files (vite.config.js, postcss.config.js, and tailwind.config.js). Hence returned an error.

I tried running vite build on local and all good though.

wildangunawan avatar Dec 14 '22 15:12 wildangunawan

What needs to be done to fix this?

MichaelNZ85 avatar Dec 15 '22 08:12 MichaelNZ85

Is there an existing issue for this?

  • [x] I have searched the existing issues

Example public repository

No response

Description

Laravel, starting from version 9, no longer using Laravel Mix to compile frontend things. Laravel moved to Vite for this.

Therefore, yarn production during image building won't work since they're no longer have that command. image

To solve this issue, I think it's simply to change this line from yarn production to yarn build. But that will create new issue for devs that haven't moved to Vite yet. Probably adding configuration for user to select either Vite (yarn build instead) or Mix (yarn production)?

For other developers that run to this issue

This issue can be solved easily by adding "production" script in your package.json file. image

Steps To Reproduce

  1. Create a new Laravel version 9 application
  2. Run in Coolify
  3. Failing at step 5/5

Version

3.12.1

you solved this?

zhinea avatar Dec 18 '22 05:12 zhinea

Simply adding "production": "vite build" to my package.json file didn't work. Still got the same error.

MichaelNZ85 avatar Dec 18 '22 09:12 MichaelNZ85

Simply adding "production": "vite build" to my package.json file didn't work. Still got the same error.

Yeah I alr reported another issue with the Dockerfile here and here (in fact that is my reply to your comment).

What can be done now? Best bet is to create your own Dockerfile, but I'm too lazy to make one lol. I already opened another issue (#789) to add feature to edit Coolify's Dockerfile template.

For now (since I also don't understand the source code of Coolify), either make our own Dockerfile (feel free to share here) or wait until Coolify team respond and solve the issue.

wildangunawan avatar Dec 18 '22 09:12 wildangunawan

If someone could make a Dockerfile and share it here, that would be great. I'm not familiar enough with Docker to do it myself.

MichaelNZ85 avatar Dec 23 '22 11:12 MichaelNZ85

Not for ARM

FROM node:18-slim as build
WORKDIR /app

COPY *.json *.js /app/
COPY resources /app/resources
RUN npm install && npm run build

# Production build
FROM webdevops/php-nginx:8.2-alpine
ENV WEB_DOCUMENT_ROOT=/app/public
WORKDIR /app
COPY --chown=application:application composer.* ./
COPY --chown=application:application database/ database/
RUN composer install --ignore-platform-reqs --no-interaction --no-plugins --no-scripts --prefer-dist

COPY --chown=application:application . ./
COPY --from=build /app/public/build /app/public/build

RUN php artisan optimize
RUN php artisan config:clear

wallaceosmar avatar Dec 23 '22 17:12 wallaceosmar

Has this been fixed yet?

EDIT: No, it hasn't - just checked. Can this be added to the next release please?

MichaelNZ85 avatar Mar 02 '23 09:03 MichaelNZ85

I'm here with a question that might be related, sorry, I know close to nothing about Laravel. My build of https://github.com/mitchy-crypto/cryptosite.git fails because "composer not found", I can see Composer is a package download on Ubuntu but am I supposed to trigger it somehow with these yarn finesses or is the problem even deeper?

c0demon avatar Mar 04 '23 11:03 c0demon

What's the latest with this?

MichaelNZ85 avatar Apr 02 '23 02:04 MichaelNZ85

Any update?

MichaelNZ85 avatar May 20 '23 08:05 MichaelNZ85

I'm closing this issue, because tracking features will be moved to GitHub discussions. Github issues will be only for bugs.

Version 4 is in full focus. v3 related issues will be closed, if it is not a critical bug.

Thanks for your understanding.

andrasbacsai avatar Sep 08 '23 09:09 andrasbacsai