FireBlade's avatar

NGINX server reading wrong css asset file in production following this guide https://docs.docker.com/guides/frameworks/laravel/production-setup/#create-a-docker-compose-configuration-for-production

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
1 like
2 replies
FireBlade's avatar

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

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

Please or to participate in this conversation.