-
-
Notifications
You must be signed in to change notification settings - Fork 101
use same devcontainer as home assistant core #1677
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
Changes from 8 commits
261d31e
9c4fcdc
703e8e8
f1c2e48
32e2ab5
81853c1
93ef195
6abae1d
bbf639c
40e253a
49c66d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"name": "Home Assistant Dev", | ||
"context": "..", | ||
"dockerFile": "../Dockerfile.dev", | ||
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder} && scripts/setup", | ||
"postStartCommand": "scripts/bootstrap", | ||
"containerEnv": { | ||
"PYTHONASYNCIODEBUG": "1" | ||
}, | ||
"features": { | ||
"ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {} | ||
}, | ||
"appPort": [ | ||
"9000:9000", // OCPP | ||
"8123:8123", // Home Assistant | ||
"5683:5683/udp" // Shelly integration | ||
], | ||
"runArgs": [ | ||
"-e", | ||
"GIT_EDITOR=code --wait", | ||
"--security-opt", | ||
"label=disable" | ||
], | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"charliermarsh.ruff", | ||
"ms-python.pylint", | ||
"ms-python.vscode-pylance", | ||
"visualstudioexptteam.vscodeintellicode", | ||
"redhat.vscode-yaml", | ||
"esbenp.prettier-vscode", | ||
"GitHub.vscode-pull-request-github", | ||
"GitHub.copilot" | ||
], | ||
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json | ||
"settings": { | ||
"python.experiments.optOutFrom": [ | ||
"pythonTestAdapter" | ||
], | ||
"python.defaultInterpreterPath": "/home/vscode/.local/ha-venv/bin/python", | ||
"python.pythonPath": "/home/vscode/.local/ha-venv/bin/python", | ||
"python.terminal.activateEnvInCurrentTerminal": true, | ||
"python.testing.pytestArgs": [ | ||
"--no-cov" | ||
], | ||
"pylint.importStrategy": "fromEnvironment", | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": true, | ||
"files.trimTrailingWhitespace": true, | ||
"terminal.integrated.profiles.linux": { | ||
"zsh": { | ||
"path": "/usr/bin/zsh" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
"yaml.customTags": [ | ||
"!input scalar", | ||
"!secret scalar", | ||
"!include_dir_named scalar", | ||
"!include_dir_list scalar", | ||
"!include_dir_merge_list scalar", | ||
"!include_dir_merge_named scalar" | ||
], | ||
"[python]": { | ||
"editor.defaultFormatter": "charliermarsh.ruff" | ||
}, | ||
"json.schemas": [ | ||
{ | ||
"fileMatch": [ | ||
"homeassistant/components/*/manifest.json" | ||
], | ||
"url": "${containerWorkspaceFolder}/scripts/json_schemas/manifest_schema.json" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,63 @@ | ||||||||||||||||
# Automatically generated by hassfest. | ||||||||||||||||
# | ||||||||||||||||
# To update, run python3 -m script.hassfest -p docker | ||||||||||||||||
ARG BUILD_FROM | ||||||||||||||||
FROM ${BUILD_FROM} | ||||||||||||||||
|
||||||||||||||||
# Synchronize with homeassistant/core.py:async_stop | ||||||||||||||||
ENV \ | ||||||||||||||||
S6_SERVICES_GRACETIME=240000 \ | ||||||||||||||||
UV_SYSTEM_PYTHON=true \ | ||||||||||||||||
UV_NO_CACHE=true | ||||||||||||||||
|
||||||||||||||||
ARG QEMU_CPU | ||||||||||||||||
|
||||||||||||||||
# Home Assistant S6-Overlay | ||||||||||||||||
COPY rootfs / | ||||||||||||||||
|
||||||||||||||||
# Needs to be redefined inside the FROM statement to be set for RUN commands | ||||||||||||||||
ARG BUILD_ARCH | ||||||||||||||||
# Get go2rtc binary | ||||||||||||||||
RUN \ | ||||||||||||||||
case "${BUILD_ARCH}" in \ | ||||||||||||||||
"aarch64") go2rtc_suffix='arm64' ;; \ | ||||||||||||||||
"armhf") go2rtc_suffix='armv6' ;; \ | ||||||||||||||||
"armv7") go2rtc_suffix='arm' ;; \ | ||||||||||||||||
*) go2rtc_suffix=${BUILD_ARCH} ;; \ | ||||||||||||||||
esac \ | ||||||||||||||||
&& curl -L https://github.com/AlexxIT/go2rtc/releases/download/v1.9.9/go2rtc_linux_${go2rtc_suffix} --output /bin/go2rtc \ | ||||||||||||||||
&& chmod +x /bin/go2rtc \ | ||||||||||||||||
# Verify go2rtc can be executed | ||||||||||||||||
&& go2rtc --version | ||||||||||||||||
|
||||||||||||||||
# Install uv | ||||||||||||||||
RUN pip3 install uv==0.7.1 | ||||||||||||||||
|
||||||||||||||||
WORKDIR /usr/src | ||||||||||||||||
|
||||||||||||||||
## Setup Home Assistant Core dependencies | ||||||||||||||||
COPY requirements.txt homeassistant/ | ||||||||||||||||
COPY homeassistant/package_constraints.txt homeassistant/homeassistant/ | ||||||||||||||||
RUN \ | ||||||||||||||||
uv pip install \ | ||||||||||||||||
--no-build \ | ||||||||||||||||
-r homeassistant/requirements.txt | ||||||||||||||||
|
||||||||||||||||
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. 🛠️ Refactor suggestion Package constraints file copied but not applied
- uv pip install \
- --no-build \
- -r homeassistant/requirements.txt
+ uv pip install \
+ --no-build \
+ -r homeassistant/requirements.txt \
+ --constraint homeassistant/homeassistant/package_constraints.txt 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||
COPY requirements_all.txt home_assistant_frontend-* home_assistant_intents-* homeassistant/ | ||||||||||||||||
RUN \ | ||||||||||||||||
if ls homeassistant/home_assistant_*.whl 1> /dev/null 2>&1; then \ | ||||||||||||||||
uv pip install homeassistant/home_assistant_*.whl; \ | ||||||||||||||||
fi \ | ||||||||||||||||
&& uv pip install \ | ||||||||||||||||
--no-build \ | ||||||||||||||||
-r homeassistant/requirements_all.txt | ||||||||||||||||
|
||||||||||||||||
## Setup Home Assistant Core | ||||||||||||||||
COPY . homeassistant/ | ||||||||||||||||
RUN \ | ||||||||||||||||
uv pip install \ | ||||||||||||||||
-e ./homeassistant \ | ||||||||||||||||
&& python3 -m compileall \ | ||||||||||||||||
homeassistant/homeassistant | ||||||||||||||||
|
||||||||||||||||
WORKDIR /config |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||||||||||||||||||||
FROM mcr.microsoft.com/vscode/devcontainers/base:debian | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
RUN \ | ||||||||||||||||||||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ | ||||||||||||||||||||||||
&& apt-get update \ | ||||||||||||||||||||||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||||||||||||||||||||||||
Comment on lines
+5
to
+8
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. 🛠️ Refactor suggestion
-curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
+curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | \
+ gpg --dearmor -o /etc/apt/keyrings/yarn.gpg && \
+echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/yarn.gpg] \
+ https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
# Additional library needed by some tests and accordingly by VScode Tests Discovery | ||||||||||||||||||||||||
bluez \ | ||||||||||||||||||||||||
ffmpeg \ | ||||||||||||||||||||||||
libudev-dev \ | ||||||||||||||||||||||||
libavformat-dev \ | ||||||||||||||||||||||||
libavcodec-dev \ | ||||||||||||||||||||||||
libavdevice-dev \ | ||||||||||||||||||||||||
libavutil-dev \ | ||||||||||||||||||||||||
libgammu-dev \ | ||||||||||||||||||||||||
libswscale-dev \ | ||||||||||||||||||||||||
libswresample-dev \ | ||||||||||||||||||||||||
libavfilter-dev \ | ||||||||||||||||||||||||
libpcap-dev \ | ||||||||||||||||||||||||
libturbojpeg0 \ | ||||||||||||||||||||||||
libyaml-dev \ | ||||||||||||||||||||||||
libxml2 \ | ||||||||||||||||||||||||
git \ | ||||||||||||||||||||||||
cmake \ | ||||||||||||||||||||||||
autoconf \ | ||||||||||||||||||||||||
&& apt-get clean \ | ||||||||||||||||||||||||
&& rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
# Add go2rtc binary | ||||||||||||||||||||||||
COPY --from=ghcr.io/alexxit/go2rtc:latest /usr/local/bin/go2rtc /bin/go2rtc | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
WORKDIR /usr/src | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
+31
to
+37
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. Images pulled with Both -COPY --from=ghcr.io/alexxit/go2rtc:latest /usr/local/bin/go2rtc /bin/go2rtc
+COPY --from=ghcr.io/alexxit/go2rtc:v1.9.9@sha256:<digest> /usr/local/bin/go2rtc /bin/go2rtc Do the same for the 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
RUN uv python install 3.13.2 | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
USER vscode | ||||||||||||||||||||||||
ENV VIRTUAL_ENV="/home/vscode/.local/ha-venv" | ||||||||||||||||||||||||
RUN uv venv $VIRTUAL_ENV | ||||||||||||||||||||||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
WORKDIR /tmp | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
# Setup hass-release | ||||||||||||||||||||||||
RUN git clone --depth 1 https://github.com/home-assistant/hass-release ~/hass-release \ | ||||||||||||||||||||||||
&& uv pip install -e ~/hass-release/ | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
# Install Python dependencies from requirements | ||||||||||||||||||||||||
COPY requirements.txt ./ | ||||||||||||||||||||||||
COPY homeassistant/package_constraints.txt homeassistant/package_constraints.txt | ||||||||||||||||||||||||
RUN uv pip install -r requirements.txt | ||||||||||||||||||||||||
COPY requirements_test.txt requirements_test_pre_commit.txt ./ | ||||||||||||||||||||||||
RUN uv pip install -r requirements_test.txt | ||||||||||||||||||||||||
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. 🛠️ Refactor suggestion Constraints not respected during dev dependency install As in the production Dockerfile, the install lines omit -uv pip install -r requirements.txt
+uv pip install -r requirements.txt --constraint homeassistant/package_constraints.txt Apply the same for
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
WORKDIR /workspaces | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
# Set the default shell to bash instead of sh | ||||||||||||||||||||||||
ENV SHELL=/bin/bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
# Resolve all dependencies that the application requires to run. | ||
|
||
# Stop on errors | ||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
python3 -m pip install -r requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add checksum / signature verification for downloaded
go2rtc
binaryThe image blindly downloads an executable from GitHub and runs it.
Without verifying a checksum / GPG signature this is a supply-chain risk: the URL can be hijacked or the asset replaced, and the malicious binary would run during build time with root privileges.
At minimum, fetch the release’s SHA-256 from the GitHub API (or bundle a known hash in the repo) and validate it before
chmod +x
.📝 Committable suggestion
🤖 Prompt for AI Agents