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

ahmedde's avatar

Permission issues while dockerizing Laravel App for production

This is a Laravel-Vue-Inertia App.

This works well:

docker-compose.yml

Dockerfile

entrypoint.sh

# All of these permissions lines has no effect

chown -R www-data:www-data .    
find /var/www/ -type d -exec chmod 755 {} \;
find /var/www/ -type f -exec chmod 644 {} \;
chmod 600 /var/www/.env
chmod -R 755 /var/www/storage
chmod -R 755 /var/www/bootstrap/cache

echo "Starting PHP-FPM"
php-fpm

executing ls -la inside the container shows that all files are owned by nobody:nogroup with permissions 777.

I concluded that it's because it's referencing my local project, so I removed - ./:/var/www in app->volumes. Now, all the permissions are set correctly and owned by www-data.

Problem is

After changing the owner and permissions to www-data, the app is no longer loading and full of 404 errors:


       GET http://localhost:8080/build/assets/app-DCXnU3p8.css net::ERR_ABORTED 404 (Not Found)Understand this error
build/assets/Login-DzgtpemJ.js:1 
        
       GET http://localhost:8080/build/assets/Login-DzgtpemJ.js net::ERR_ABORTED 404 (Not Found)Understand this error
build/assets/app-DqDhRdxO.js:1 
        

Even though the build was successful, and the files chrome tries to fetch are there is /public/build/assets.

Any help would be much appreciated!

0 likes
0 replies

Please or to participate in this conversation.