Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Fixed devcontainer permissions #438

Merged
merged 1 commit into from
Jun 23, 2022
Merged

[1.x] Fixed devcontainer permissions #438

merged 1 commit into from
Jun 23, 2022

Conversation

Random72IsTaken
Copy link
Contributor

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 regular sail 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

  • curl -s "https://laravel.build/example-app?devcontainer" | bash
    code -r example-app/
    • If the Remote-Containers: Reopen in Container command is used without the "fix", and once the setup is done, all files are owned by root:root; throwing the exceptions shown at the top.

    • If the "postCreateCommand": "chown -R 1000:1000 /var/www/html" was added first in devcontainer.json, and then built the container instead; or possibly just ran Remote-Containers: Rebuild Without Cache and Reopen in Container; then the files are owned by sail:sail and everybody is happy. 🙃

      2022-06-23_11-00

@taylorotwell taylorotwell merged commit 52a14c0 into laravel:1.x Jun 23, 2022
@taylorotwell
Copy link
Member

@videlalvaro what do you think of this PR? is it correct?

@videlalvaro
Copy link
Contributor

Hey @taylorotwell I was out, and just saw this.

I think it's correct, but there was a workaround where you setup

WWWGROUP=1000
WWWUSER=1000

in your .env file, and that was enough.

While the PR is more user friendly, that config change feels less intrusive

@Random72IsTaken
Copy link
Contributor Author

But when I was testing the setup, I double-checked that .env has these variables, and concluded that they did not affect the permissions in the end... 🤷

@videlalvaro
Copy link
Contributor

I had the opposite experience :D I had to setup that to make it work :)

@Random72IsTaken
Copy link
Contributor Author

Dang... Has to be an Ubuntu thing then. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants