[1.x] Fixed devcontainer permissions #438
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If I create a Laravel application in a DevEnvrionment (while following the docs), all file permissions inside the container are set to
root:root
, which throws permission exceptions; such as this: https://flareapp.io/share/qm1036q5#F11.Decision
I thought about what's been discussed in the issue [ #435 ] I've submitted before, and I don't think documentation is the solution. Since, to my understanding, there's no other way to work with the DevContainer files from VSC nor access them from the browser than owning them by
sail
user! And if there is one, then I'd love to learn about it. 🙂So why wouldn't we add a line somewhere instead of forcing the user to learn about a lot of Linux commands, Laravel file structure and permissions, and before even reaching the app's home page; possibly!
Solution
Also considering the weird situation, it seems like adding a command in the
start-container
file would feel intrusive, since there's still that regularsail
use-case without a DevContainer!Therefore, I've utilized the commented-out life-cycle line in
devcontainer.json
itself to set the permissions manually.Setup
I've done the following via Ubuntu 22.04 and VSC with Remote Development extension.
Steps
If the
Remote-Containers: Reopen in Container
command is used without the "fix", and once the setup is done, all files are owned byroot:root
; throwing the exceptions shown at the top.If the
"postCreateCommand": "chown -R 1000:1000 /var/www/html"
was added first indevcontainer.json
, and then built the container instead; or possibly just ranRemote-Containers: Rebuild Without Cache and Reopen in Container
; then the files are owned bysail:sail
and everybody is happy. 🙃