Laravel deployment fails due to wayfinder

Hey there,

I just tried to deploy the laravel + vue starter-kit and wasn’t successful with that.

...
FROM node:${NODE_VERSION} as node_modules_go_brrr 
RUN mkdir /app 
RUN mkdir -p /app 
WORKDIR /app 
COPY . .
COPY --from=base /var/www/html/vendor /app/vendor 

# Use yarn or npm depending on what type of # lock file we might find. Defaults to # NPM if no lock file is found. 
# Note: We run "production" for Mix and "build" for Vite 
RUN if [ -f "vite.config.js" ] || <- FAILS HERE
...

Error msg (partly):

[@laravel/vite-plugin-wayfinder] [plugin @laravel/vite-plugin-wayfinder] Error generating types: Error: Command failed: php artisan wayfinder:generate --with-form 9.781 /bin/sh: 1: php: not found

As I see it now, the second stage in the generated Dockerfile triggers the vite build process, which also runs wayfinder. But wayfinder needs php, which is not present in the FROM node:${NODE_VERSION} stage.

After some tries, my workaround is to change the second stage from the above to:

FROM base as node_modules_go_brrr

# new
RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh \
    && bash nodesource_setup.sh \
    && apt install nodejs -y

RUN mkdir /app

RUN mkdir -p  /app
WORKDIR /app
COPY . .
COPY --from=base /var/www/html/vendor /app/vendor

That way I just use the base image with php installed and add npm and node to it.
As I am fairly new to Laravel and web in general I am unsure what exactly was the problem. Is this a viable solution? Is this a general setup error of the fly.io Dockerfile presets?

edit: typo