FireBlade's avatar

FireBlade liked a comment+100 XP

2w ago

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

FireBlade's avatar

FireBlade wrote a reply+100 XP

2w ago

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...

FireBlade's avatar

FireBlade wrote a reply+100 XP

2w ago

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

FireBlade's avatar

FireBlade started a new conversation+100 XP

3w ago

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...

FireBlade's avatar

FireBlade wrote a reply+100 XP

3w ago

I have noticed that the NGINX container has different build asset files compared to the PHP-FPM one. It looks like the process flow presented by the guide that favors 2 Dockerfiles is at fault ...What if we had 1 Dockerfile and the containers pick the relevant stages from the same Dockerfile...

FireBlade's avatar

FireBlade wrote a reply+100 XP

4w ago

I have also noticed that files and folders in the NGINX server are owned by root. I have tried several options including building with --no-cache option but still NGINX tries to read exactly same non-existent file.

FireBlade's avatar

FireBlade started a new conversation+100 XP

4w ago

For my setup, the Laravel app is inside src folder while all other docker setup files are outside src folder. My Dockerfile for NGINX container:

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 is:

And the docker-compose.yml file is:

The problem is that when I deploy the app, NGINX server is reading non-existent CSS file:

"GET /build/assets/app-6483e3d7.css HTTP/1.0" 404 6603

instead of the one actually deployed to the build assets folder, leading to a broken CSS page:

app-b3fca3b4.css
FireBlade's avatar

FireBlade wrote a reply+100 XP

2mos ago

I have also realized that this Tailwind style is not working in a Blade component in production ( this is not in welcome.blade.php as noted above) :

html class="bg-green-700">

forcing me to resort to plain css: html style="background-color:#46854f

My vite.config.js

import { defineConfig } from 'vite';
import laravel, { refreshPaths } from 'laravel-vite-plugin';

export default defineConfig({
    server: {
        host: '0.0.0.0',
        port: 5173,
        strictPort: true,
        hmr: {
            host: '127.0.0.1'
        }
    },
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
            ],
            refresh: [
                ...refreshPaths,
                'app/Http/Livewire/**',
            ],
        }),
    ],
});

Am in Laravel 9.52.21

FireBlade's avatar

FireBlade wrote a reply+100 XP

2mos ago

Looks like this line is not processed in production:

<!-- Scripts -->
        @vite(['resources/css/app.css', 'resources/js/app.js'])
FireBlade's avatar

FireBlade wrote a reply+100 XP

2mos ago

The Dockerfile has the command:

RUN npm install && npm run build

and the output is deployed here:

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

FireBlade's avatar

FireBlade started a new conversation+100 XP

2mos ago

I have a single-page app using only the welcome.blade.php file:

This is the NGINX container Dockerfile:

FROM debian AS builder

# Install Node.js and build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    nodejs \
    npm \
    && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set working directory
WORKDIR /var/www

# Copy Laravel application code
COPY ./src/. /var/www

RUN npm install && npm run build

FROM nginx:1.21-alpine

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

WORKDIR /var/www/public

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

The problem is that once deployed in production, the page looks ugly:

  1. The custom font Epilogue is not being used. Its actually using a font that I believe I used once sometime ago.
  2. Tailwind CSS on the header element is not applied.

On my development machine, the page looks OK when running Vite development server. Any help is appreciated...

FireBlade's avatar

FireBlade liked a comment+100 XP

2mos ago

You're running the php artisan command in the NGINX container instead of the PHP container, that's why you getting the error message.

FireBlade's avatar

FireBlade liked a comment+100 XP

2mos ago

Bit rusty on Docker, but I'll do my best to help.

Have you verified that the public/storage symlink exists inside the Nginx container, not just the PHP container?

Since you're using separate Nginx and PHP-FPM containers, php artisan storage:link runs in the PHP container — but Nginx is the one serving static files.

In your Nginx Dockerfile you only copy:

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

That means:

The storage directory is not copied

The symlink created in the PHP container is not present

There is no shared volume between containers

So when the browser requests /storage/..., Nginx simply doesn’t have that path — hence the 404.

You have a few options:

Share the entire project directory as a Docker volume between Nginx and PHP

Build both containers from the same source layer so storage and the symlink exist in both

If these are static assets that ship with your app (like quote.svg), consider placing them directly in /public/img instead of storage

Right now, Nginx has no access to the storage directory, which is almost certainly the issue.

FireBlade's avatar

FireBlade wrote a reply+100 XP

2mos ago

I tried rebuilding the NGINX image and I get this error:

Step 6/15 : RUN php artisan storage:link
 ---> Running in a8c64eeb9323
/bin/sh: 1: php: not found

I am considering building the images as you suggest...

FireBlade's avatar

FireBlade started a new conversation+100 XP

2mos ago

This is my NGINX production Dockerfile :

This is my PHP-FPM Dockerfile :

However, when I start the Laravel app, images are not showing. I even tried adding an image on the welcome.blade.php file as:

<img src="{{asset('/storage/img/quote.svg')}}" alt="">
    </body>
</html>

but on Chrome Developer tools, it shows error 404. Kindly help...

FireBlade's avatar

FireBlade wrote a reply+100 XP

5mos ago

livewire/livewire v2.12.1 A front-end framework ...

FireBlade's avatar

FireBlade wrote a reply+100 XP

5mos ago

When i try it like this I also get array:

@foreach($posts as $post)  
        @if($canDelete)    
              <x-jet-dropdown-link rel="nofollow" href="#!"
                      @click="Livewire.emit('setDeleteRecord',{{App\Models\Post::find($post->id)}});">
                                 {{ __('Delete') }}
              </x-jet-dropdown-link>
              <div class="border-t border-gray-100"></div>
         @endif 
@endforeach
FireBlade's avatar

FireBlade wrote a reply+100 XP

5mos ago

Laravel Framework 9.52.4

FireBlade's avatar

FireBlade wrote a reply+100 XP

5mos ago

When I write the blade view like this :

@foreach($posts as $post)  
        @if($canDelete)    
              <x-jet-dropdown-link rel="nofollow" href="#!"
                      @click="Livewire.emit('setDeleteRecord',{{$post}});">
                                 {{ __('Delete') }}
              </x-jet-dropdown-link>
              <div class="border-t border-gray-100"></div>
         @endif 
@endforeach

The Livewire component does not work:

if($this->model instanceof App\Models\Post) $this->model->delete();

I get an array instead of object.

FireBlade's avatar

FireBlade wrote a reply+100 XP

5mos ago

Yes. There's an authorization check so this is not the issue...

FireBlade's avatar

FireBlade wrote a reply+100 XP

5mos ago

This is how I delete the model:

if ($this->model == 'Post')Post::find($this->recordId)->delete(); elseif 
FireBlade's avatar

FireBlade started a new conversation+100 XP

5mos ago

I have a Livewire component that deletes models :

...

    
    public function setRecord($model,$recordId){
        $this->resetDialog();
        $this->model = $model;
        $this->recordId = $recordId;
    }
...
setRecord is called from Blade template :

```php
@if($canDelete)    
      <x-jet-dropdown-link @click="Livewire.emit('setDeleteRecord','Post',{{$row->id}});">
              {{ __('Delete') }}
      </x-jet-dropdown-link>
      <div class="border-t border-gray-100"></div>
@endif

How can I simplify pass the model from the Blade template without the manual model type "Post" and still delete the model ? Remember I plan to use the same Livewire component with different models eg Item, Location etc ?