laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.68k stars 475 forks source link

Fix root user bug and replace hardcoded `sail` user with env variable #636

Closed calebdw closed 11 months ago

calebdw commented 11 months ago

Hello!

Firstly, this PR fixes a bug where the command sail root-shell does not open a root shell for containers that are not running as the root user (by switching users with USER <user> in the Dockerfile). The simple fix is to just specify the root user in the command.

Secondly, this PR replaces the hardcoded sail user with the (unused) WWWUSER variable that's already defined in the sail script:

https://github.com/laravel/sail/blob/7150fe03a94e7cd77b8042ddbb55c7ed20c4bca0/bin/sail#L137-L142

This gives the developer greater flexibility and allows the sail script to work with containers that don't have a sail user defined. For example, the project I work on has its own Dockerfiles and custom user, the only reason why I use this package is for the neat sail command to easily proxy commands into the containers---however, I can't use the script as-is due to the hardcoded sail user which doesn't exist inside the container.

Thanks!

taylorotwell commented 11 months ago

Pushed a fix for the root thing, but don't really want to change anything else.