Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shaungbhone's avatar

All css and javascript file not found in prodction.

We're using the docker in production. Our laravel app public assets are not found. What's happening?

https://filamenterp.com/

0 likes
1 reply
LaryAI's avatar
Level 58

It sounds like your assets are not being correctly served in your production environment. This can happen for a variety of reasons, but here are a few common issues and solutions:

  1. Incorrect Volume Mapping in Docker: Ensure that your Docker configuration is correctly mapping your project's public directory to the web server's root directory.

  2. Incorrect Web Server Configuration: If you're using Nginx or Apache inside your Docker container, make sure that the server is configured to serve files from the correct directory.

  3. File Permissions: Sometimes, file permissions can cause issues. Ensure that the web server process has the necessary permissions to read files from the public directory.

  4. Incorrect Asset URLs: If you're using Laravel's asset() or mix() helpers to generate URLs and you're behind a load balancer or reverse proxy, you might need to set the ASSET_URL in your .env file to the correct base URL.

Here's a checklist to troubleshoot the issue:

  • Check your Docker container's volume mappings. For example, if you're using docker-compose, your docker-compose.yml should have something like this:
services:
  web:
    volumes:
      - ./public:/var/www/html/public
  • Verify your web server configuration. For Nginx, your server block should have a root directive pointing to the public directory:
server {
    listen 80;
    root /var/www/html/public;
    index index.php index.html index.htm;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    # other configurations...
}
  • Check file permissions. You might need to set the correct permissions on your public directory:
sudo chown -R www-data:www-data /path/to/your/laravel/public
sudo chmod -R 755 /path/to/your/laravel/public
  • Set the ASSET_URL in your .env file if necessary:
ASSET_URL=https://filamenterp.com

After making changes, don't forget to clear your Laravel cache and potentially your browser cache as well:

php artisan config:cache
php artisan cache:clear

If you've gone through these steps and your assets are still not being served correctly, you may need to provide more specific information about your Docker setup and web server configuration for further assistance.

Please or to participate in this conversation.