-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
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
Add non-root dev container user #34984
Conversation
Please note, that this will impact the running Home Assistant inside the container, as it will have fewer permissions as well. |
Yeah, I've still got some bugs to work out as well regarding the install permissions. I thought everything was working when I opened this PR, but it appears there is still some things a little wonky. Edit: What are known things that HA needs to run as root in order to be able to do? Previous dev was run in non-root venv anyway. The fact that this dev container uses appPort instead of on the host network breaks more integrations than I would imagine running as a non-root user would. |
latest commit should fix homeassistant editable install issue. |
@pvizeli - Would you care to provide any context around closing? |
Probably a mistake, as otherwise we would have seen a comment. Re-opening. |
Repeat the last one: Indent, that is a an issue with container general but this is not the fix general, it just fix your use case. You will have this issue every time you use devcontainer in your setup. Let's hope docker fix the issue with a permission manager which can adapt to microsoft devcontainer and hope full also to our other images. To fix this use case, I would say we remove devcontainer with git ignore and make templates to developer documentation. Everybody can select this template for his use case until the world have a fix for everybody. |
I agree that it's a general docker issue with mounted volumes on Linux, but it's not an issue with every devcontainer. All out of the box dev containers provided by Microsoft have this addition, including the python dev container. If this Dockerfile were used for anything other than spinning up a VSCode devcontainer, I would agree that this change shoudn't be added. If Home Assistant is going to provide a devcontainer for users, it should match at least the recommendations made by VSCode. The last sentence in that statement you quoted is in reference to OS containers or Application containers who do not add a non-root user. The context would be different if this were a PR against https://github.com/home-assistant/docker, but it's a PR here on If you'd like, I can remove the |
I have to agree with Hunterjm here. IMO the sole purpose of adding |
I simplified this PR which achieves the same result when using this {
"name": "Home Assistant Dev",
"context": "..",
"dockerFile": "../Dockerfile.dev",
"remoteUser": "vscode",
"postCreateCommand": "mkdir -p config && pip3 install --no-use-pep517 --user -e .",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--net=host"],
"extensions": [
"ms-python.python",
"visualstudioexptteam.vscodeintellicode",
"ms-azure-devops.azure-pipelines",
"redhat.vscode-yaml",
"esbenp.prettier-vscode"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.shell.linux": "/bin/bash",
"yaml.customTags": [
"!secret scalar",
"!include_dir_named scalar",
"!include_dir_list scalar",
"!include_dir_merge_list scalar",
"!include_dir_merge_named scalar"
]
}
} Note I also changed to |
If it is recommended in the remote container docs, it sounds reasonable to add it. @pvizeli what would be against adding this? It fixes Linux development, so that's good. Does it break Windows development? net=host seems also like a good idea. I just saw this posted 20 min ago in |
In case of that, we can also use the base image from Microsoft: I don't see a reason to maintain the own if there is a solution they include this part now.
Please not. It's just a developer env to test the code and not run Home Assistant as @hunterjm described. It affects me not on windows because they run anyway in a virtual Network split from physical, but it breaks the local installation i.e. with zeroconf since we handle that wrong and an instance overwrites the exists one as an example. We should not mix up productive instances and references with developer ones. If someone needs to test something in the real network, he can modify the parameter for a test. |
I agree with @pvizeli regarding using the host network. That only works on Linux, and would break Windows/Mac containers because port 8123 would no longer be forwarded. I’m also Ok switching to use the Microsoft image as the base, but think it is helpful to install some of the other I still don’t know the best answer regarding Having it untracked would mean there is an extra step that would need to be documented in the setup docs for devs, but we could give more detailed recommendations based on the host OS... |
We should have a default one that works out of the box for most people, and can offer a gitignore for a I agree that the devcontainer doesn't need to support production and that it's for development, however there is a bunch of development done that also relies on discovery. |
So we put our devcontainer on top of the vscode provided standard image, so we are sure that we are up to date for vscode solution to make it working on most as possible systems. Now it's still the question about the host. Maybe we should today not until we fix our mdns mistake and avoid issues which would be comes if we change that. After that we can move to host network. |
That sounds good. That way we also have to maintain less 👍 |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
I changed base to the |
Breaking change
Proposed change
Adds default non-root user to dev container with sudo permissions based on recommendation from Microsoft to fix file permission issue when developing on a linux machine.
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: