FireBlade's avatar

Bundled Alpinejs not working in Laravel Docker

I have a fresh new Laravel 9 Jetstream-Livewire app with the node_modules and vendor folders deleted. The NGINX container Dockerfile looks like this:

FROM node:22-alpine AS builder

WORKDIR /app

# Copy Laravel application code
COPY ./src/. /app

RUN npm install && npm run build

FROM nginx:1.21-alpine

COPY --from=builder /app/public /var/www/public

COPY ./nginx/nginx.conf /etc/nginx/conf.d/nginx.conf

WORKDIR /var/www/public

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

The main Dockerfile looks like this:

However, Alpinejs is not working and the browser console does not show any error...

0 likes
6 replies
FireBlade's avatar

I have a project in Laravel 9 that I haven't migrated or upgraded where I noticed the problem, so I created a new Laravel 9 project to confirm that the issue was not just that old project ...I believe I will face the same issue even in other versions no ? Kindly assist. Thanks

martinbean's avatar

@fireblade No one can assist without seeing the actual error, or the code where you try and include Alpine.

1 like
FireBlade's avatar

Confirmed. I removed all extra code and added the most basic Alpinejs code and found that its working. I think the problem was the code...Thanks a lot...

abdul_rehman333's avatar

How is this project running with 8.4 PHP and laravel 9 ? I'm confused

Please or to participate in this conversation.