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

Add generic guide to setup devcontainer environment #2227

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/development_environment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You'll need to set up a development environment if you want to develop a new fea

## Developing with Visual Studio Code + devcontainer

The easiest way to get started with development is to use Visual Studio Code with devcontainers. This approach will create a preconfigured development environment with all the tools you need. This approach is enabled for all Home Assistant repositories. [Learn more about devcontainers.](https://code.visualstudio.com/docs/devcontainers/containers)
Follow our [devcontainer development environment](/docs/setup_devcontainer_environment) guide to set up a proper development environment first.
frenck marked this conversation as resolved.
Show resolved Hide resolved

:::note
As this approach uses containers, you may face challenges exposing hardware like USB devices & adapters (onboard Bluetooth, Zigbee, ...) into the container for testing. This is possible when developing on a Linux host; however, you cannot directly access such hardware if you are using a Windows or MacOS computer for development.
Expand Down
2 changes: 2 additions & 0 deletions docs/frontend/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Do not use development mode in production. Home Assistant uses aggressive cachin

## Setting up the environment

Follow our [devcontainer development environment](/docs/setup_devcontainer_environment) guide to set up a proper development environment first.
frenck marked this conversation as resolved.
Show resolved Hide resolved

### Getting the code

The first step is to fork the [frontend repository][hass-frontend] and add the upstream remote. You can place the forked repository anywhere on your system.
Expand Down
130 changes: 130 additions & 0 deletions docs/setup_devcontainer_environment.mdx
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title: "Setting Up a Devcontainer Development Environment"
---
title: "Setting Up the Devcontainer Development Environment"
---


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).
Copy link
Contributor

Choose a reason for hiding this comment

The 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).

Committable suggestion was skipped due to low confidence.


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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
Tools
LanguageTool

[uncategorized] ~45-~45: You might be missing the article “a” here.
Context: ...Since the Docker engine is installed as systemd service, we need to ensure systemd supp...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


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"
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Follow "Setup on Linux"
### Follow "Setup on Linux"


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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.


## Fork the repository and start the devcontainer
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Fork the repository and start the devcontainer
## Fork the repository and start the devcontainer.


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".
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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**.

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>
3 changes: 2 additions & 1 deletion docs/supervisor/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ title: "Supervisor development"
sidebar_label: "Development"
---

These instructions are for development of the Supervisor, the Supervisor frontend panel and the `hassio` integration, by interacting with a development or remote supervisor, this assumes that you are using a development machine to do the development, these instructions will also use devcontainer and other tools that rely on Docker, so if you don't have that setup yet, do that before you continue.
These instructions are for development of the Supervisor, the Supervisor frontend panel and the `hassio` integration, by interacting with a development or remote supervisor, this assumes that you are using a development machine to do the development, these instructions will also use devcontainer and other tools that rely on Docker, follow our [devcontainer development environment](/docs/setup_devcontainer_environment) guide to set up a proper development environment first.
mib1185 marked this conversation as resolved.
Show resolved Hide resolved


## Supervisor development

Expand Down
5 changes: 4 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ module.exports = {
"add-ons/repository",
"add-ons/security",
],
Overview: ["architecture_index"],
Overview: [
"architecture_index",
"setup_devcontainer_environment"
],
Frontend: [
"frontend",
"frontend/architecture",
Expand Down
Binary file added static/img/en/development/reopen_in_container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.