-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add generic guide to setup devcontainer environment #2227
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
base: master
Are you sure you want to change the base?
Changes from 6 commits
4d66942
920b856
8d36b6a
674a822
a1d52f6
5c254c9
9550ac3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,130 @@ | ||||||||||
--- | ||||||||||
title: "Setting Up a Devcontainer Development Environment" | ||||||||||
--- | ||||||||||
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update document title for clarity and consistency. Consider using a more descriptive and consistent title format. The current title could be enhanced to align with common documentation practices. - title: "Setting Up a Devcontainer Development Environment"
+ title: "Setting Up the Devcontainer Development Environment" Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
The easiest way to get started with development is to use Visual Studio Code with [devcontainers](https://code.visualstudio.com/docs/devcontainers/containers). This approach creates a preconfigured development environment with the necessary tools. This approach is enabled for all Home Assistant repositories. Since the Docker-based devcontainer concept provides a layer of abstraction, the following guides merge at one point. | ||||||||||
mib1185 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
First, install [Visual Studio code](https://code.visualstudio.com/), next follow one of the next chapters based on your system. | ||||||||||
mib1185 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
## Setup on Windows | ||||||||||
|
||||||||||
:::tip | ||||||||||
**Quick start guide** | ||||||||||
|
||||||||||
- Install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) and enable [systemd support](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/). | ||||||||||
- Install the [Docker engine](https://docs.docker.com/engine/install/) based on your selected WSL2 Linux distribution. | ||||||||||
- Fork and clone the desired code repository within the WSL2. | ||||||||||
- [Start the devcontainer](#fork-the-repository-and-start-the-devcontainer) | ||||||||||
mib1185 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
::: | ||||||||||
|
||||||||||
### Install WSL2 | ||||||||||
|
||||||||||
This section outlines the steps for Windows 10 (_version 2004 and later_) and Windows 11. If you're still running an older version, follow these [manual installation steps](https://learn.microsoft.com/en-us/windows/wsl/install-manual). | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify Windows version requirements. The phrase "based on Windows 10 version 2004 and higher or Windows 11" might confuse readers about the exact requirements. Clarifying that it applies to Windows 10 (version 2004 and later) and all versions of Windows 11 could improve understanding. - This section outlines the steps for Windows 10 (_version 2004 and later_) and Windows 11. If you're still running an older version, follow these [manual installation steps](https://learn.microsoft.com/en-us/windows/wsl/install-manual).
+ This section outlines the steps for Windows 10 (version 2004 and later) and Windows 11. If you're still running an older version, follow these [manual installation steps](https://learn.microsoft.com/en-us/windows/wsl/install-manual).
|
||||||||||
|
||||||||||
1. Run the following command in the Windows terminal to install the needed features to run WSL and install the default Ubuntu distribution: | ||||||||||
|
||||||||||
```batch | ||||||||||
wsl --install | ||||||||||
``` | ||||||||||
|
||||||||||
2. Check the WSL version, if the version is already 2, skip the "set wsl version" step. | ||||||||||
|
||||||||||
```batch | ||||||||||
wsl -l -v | ||||||||||
``` | ||||||||||
|
||||||||||
3. Set the WSL version to 2 if necessary (_replace `<distro name>` with the installed distribution name; see the output above_). | ||||||||||
|
||||||||||
```batch | ||||||||||
wsl --set-version <distro name> 2 | ||||||||||
``` | ||||||||||
|
||||||||||
### Enable systemd support in WSL2 | ||||||||||
|
||||||||||
Since the Docker engine is installed as systemd service, we need to ensure systemd support is enabled in the WSL2. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure clarity in instructions about enabling systemd support. The instruction about ensuring systemd support is enabled in WSL2 could be more explicit. It's crucial for users to understand why this step is necessary. - Since the Docker engine is installed as systemd service, we need to ensure systemd support is enabled in the WSL2.
+ Since the Docker engine requires systemd to function properly and is installed as a systemd service, it is crucial to enable systemd support in WSL2. Committable suggestion
Suggested change
ToolsLanguageTool
|
||||||||||
|
||||||||||
1. Start the WSL shell by issuing just the `wsl` command in the Windows terminal. | ||||||||||
2. Add the following lines to the `/etc/wsl.conf`; you will need to open the file with root privileges (_for example, `sudo nano /etc/wsl.conf`_): | ||||||||||
mib1185 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
```raw | ||||||||||
[boot] | ||||||||||
systemd=true | ||||||||||
``` | ||||||||||
|
||||||||||
3. Shutdown WSL2 with the following command on the Windows terminal: | ||||||||||
|
||||||||||
```batch | ||||||||||
wsl --shutdown | ||||||||||
``` | ||||||||||
|
||||||||||
4. Start the WSL shell again and run the following command to check that systemd is running: | ||||||||||
|
||||||||||
```shell | ||||||||||
systemctl list-units | ||||||||||
``` | ||||||||||
|
||||||||||
|
||||||||||
### Follow "Setup on Linux" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capitalize "Linux" in the section title. The phrase "Follow 'Setup on linux'" should have "Linux" capitalized as it is a proper noun. - ### Follow "Setup on linux"
+ ### Follow "Setup on Linux" Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
From this point on, you can follow the [Setup on Linux](#setup-on-linux) instructions below, note that all steps must be performed within the WSL2 shell. When choosing the correct steps to install the docker engine, use the installed WSL2 distribution (_the default is Ubuntu_). | ||||||||||
|
||||||||||
## Setup on Linux | ||||||||||
|
||||||||||
:::tip | ||||||||||
**Quick start guide** | ||||||||||
|
||||||||||
- Install the [Docker engine](https://docs.docker.com/engine/install/) based on your Linux distribution. | ||||||||||
- Fork and clone the desired code repository. | ||||||||||
- [Start the devcontainer](#fork-the-repository-and-start-the-devcontainer). | ||||||||||
|
||||||||||
::: | ||||||||||
|
||||||||||
### Install Docker Engine | ||||||||||
|
||||||||||
Since these instructions vary depending on your Linux distribution, we only provide a rough overview. For detailed instructions, follow the official [Docker engine](https://docs.docker.com/engine/install/) install guide. | ||||||||||
|
||||||||||
1. Update all installed packages. | ||||||||||
2. Add the Docker repository for your package manager (_like `yum` or `apt`_). | ||||||||||
3. Update your package repository package index. | ||||||||||
4. Install the Docker engine packages. | ||||||||||
5. Follow the [Linux post-installation steps for Docker Engine](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) instructions to allow non-root users to use Docker. | ||||||||||
|
||||||||||
## Setup on macOS | ||||||||||
|
||||||||||
:::tip | ||||||||||
**Quick start guide** | ||||||||||
|
||||||||||
- Install [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/). | ||||||||||
- Fork and clone the desired code repository. | ||||||||||
- [Start the devcontainer](#fork-the-repository-and-start-the-devcontainer). | ||||||||||
|
||||||||||
::: | ||||||||||
|
||||||||||
### Install Docker Desktop | ||||||||||
|
||||||||||
Since the installation steps are well documented and may change over time, we refer to the official [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/) guide. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistency in referring to the official guide. Ensure consistency in referring to the official guide for installing Docker Desktop on macOS. - Since the installation steps are well documented and may change over time, we refer to the official [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/) guide.
+ Since the installation steps are well documented and may change over time, refer to the official [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/) guide. Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
## Fork the repository and start the devcontainer | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct typographical and grammatical issues. Ensure clarity in instructions about starting the devcontainer. - ## Fork the repository and start the devcontainer
+ ## Fork the repository and start the devcontainer. Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
Since this slightly differs between our code repositories, the following is a generic guide. | ||||||||||
|
||||||||||
1. Open the desired code repository on GitHub (_for example, the [Home Assistant Core repository](https://github.com/home-assistant/core)_), and click on "fork". | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the instruction for forking the repository. Clarify the instruction for forking the repository on GitHub. - 1. Open the desired code repository on GitHub (_for example, the [Home Assistant Core repository](https://github.com/home-assistant/core)_), and click on "fork".
+ 1. Open the desired code repository on GitHub (_for example, the [Home Assistant Core repository](https://github.com/home-assistant/core)_), and click on **Fork**. Committable suggestion
Suggested change
|
||||||||||
2. Once your fork is created, copy the URL of your fork and clone it to a local directory on your computer. | ||||||||||
|
||||||||||
```shell | ||||||||||
cd $HOME | ||||||||||
git clone <URL> | ||||||||||
``` | ||||||||||
|
||||||||||
3. Change into the directory of your fork and start Visual Studio Code from there: | ||||||||||
|
||||||||||
```shell | ||||||||||
cd <FORKNAME> | ||||||||||
code . | ||||||||||
``` | ||||||||||
|
||||||||||
4. Visual Studio Code will automatically detect the devcontainer and prompt to "Reopen in Container" (_bottom right corner_) - click on it. | ||||||||||
mib1185 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
<p class='img'> | ||||||||||
<img src='/img/en/development/reopen_in_container.png' /> | ||||||||||
</p> |
Uh oh!
There was an error while loading. Please reload this page.