brefphp / laravel-bridge

Package to use Laravel on AWS Lambda with Bref
https://bref.sh/docs/frameworks/laravel.html
MIT License
314 stars 63 forks source link

Create storage directories as 777 #118

Open georgeboot opened 1 year ago

georgeboot commented 1 year ago

Create storage dirs with 777 permissions, so that php-fpm can access the directory (it runs as user nobody).

Fixes #117

mattrenner commented 1 year ago

Could be my specific use-case or environment, but might be worth noting that I ran into this problem as well but the above didn't work due to the default umask of the root user, which drops the applied permission back down to 0755.

Clearing the umask temporarily with umask(0) (and then putting it back) resolves this for me.

I'm not going to pretend I already knew this and didn't spend a morning smacking my head into the wall! https://stackoverflow.com/a/3997671

mnapoli commented 1 year ago

@mattrenner whole TIL about umask, thanks for sharing.

I'm 👍 to merge this, I don't think it hurts anything (PHP should have access to write this directory, and there shouldn't be any other user, so I don't see a security issue), but maybe we should change off and on the umask too then?

FRoepstorf commented 1 year ago

Stumbled upon the same issue, only locally though: Just changing the permissions to 0777 did not work, changing and resetting the umask did the trick!

deleugpn commented 1 year ago

The way I handle this sort of issue is to configure my local container to run with the nobody user, which matches the FPM configration that Bref ships. With docker compose it's as easy as setting your container with user: nobody.

mnapoli commented 1 year ago

@deleugpn do you see a way for us to fix this for all users? Would it make sense to change the user in Docker images for example, or could that mess things up? I haven't taken the time to dig into this.