Skip to content

Commit

Permalink
feat(home-assistant): Run in a virtualenv
Browse files Browse the repository at this point in the history
  • Loading branch information
joryirving committed Jan 6, 2025
1 parent 26a7986 commit 06c74d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/home-assistant/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV \
CRYPTOGRAPHY_DONT_BUILD_RUST=1 \
HOMEASSISTANT_WHEELS="https://wheels.home-assistant.io/musllinux/" \
HOME="/config" \
PYTHONPATH="/config/deps"
VENV_FOLDER="/config/.venv"

ENV UMASK="0002" \
TZ="Etc/UTC"
Expand Down
2 changes: 1 addition & 1 deletion apps/home-assistant/ci/goss.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml
process:
hass:
python3:
running: true
file:
/usr/local/bin/hass:
Expand Down
13 changes: 12 additions & 1 deletion apps/home-assistant/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/usr/bin/env bash
#shellcheck disable=SC2086

unset UV_SYSTEM_PYTHON
# Ensure $VENV_FOLDER directory exists.
mkdir -p "${VENV_FOLDER}"

# Create venv if required.
uv venv --system-site-packages --allow-existing "${VENV_FOLDER}"
# Install uv into the venv if required. This is needed for home-assistant to properly invoke uv to install additional deps.
uv pip freeze --system | grep ^uv= | xargs uv pip install
# Activate the venv
source "${VENV_FOLDER}/bin/activate"

if [[ "${HOME_ASSISTANT__HACS_INSTALL}" == "true" ]]; then
curl -sfSL https://get.hacs.xyz | bash -
fi

exec \
/usr/local/bin/hass \
python3 -m homeassistant \
--config /config \
"$@"

0 comments on commit 06c74d8

Please sign in to comment.