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

Added and documented pip support for installing packages. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Since version 0.107, the Home Assistant docker image uses the [S6-Overlay](https

Finally, some packages on Alpine (Home Assistant's base image) are buggy if not running as root (like ping). For that reason, the custom run script supports installing extra packages, specified in the `PACKAGES` environment variable, before starting Home Assistant.

There is also a option to install python packages in the venv, add your package to the `PIP` environment variable. See the examples below.

## Usage

Follow the [official docs] for installation inside docker. But before you start your container, make sure the script `run` is available in `/config/docker`:
Expand All @@ -33,6 +35,7 @@ docker run -d \
-e "PUID=1000" \
-e "PGID=1000" \
-e "PACKAGES=iputils" \
-e "PIP=aiogithubapi" \
-v "/PATH_TO_YOUR_CONFIG:/config" \
-v "/PATH_TO_YOUR_CONFIG/docker/run:/etc/services.d/home-assistant/run" \
--net=host \
Expand Down Expand Up @@ -64,6 +67,7 @@ home-assistant:
- PGID=1000
- UMASK=007
- PACKAGES=iputils
- PIP=aiogithubapi
volumes:
- "/PATH_TO_YOUR_CONFIG/config:/config"
- "/PATH_TO_YOUR_CONFIG/docker/run:/etc/services.d/home-assistant/run"
Expand Down
12 changes: 12 additions & 0 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PGID="${PGID:-1000}"
UMASK="${UMASK:-}"

PACKAGES="${PACKAGES:-}"
PIP="${PIP:-}"

VENV_PATH="${VENV:-/var/tmp/homeassistant-venv}"
CONFIG_PATH=/config
Expand Down Expand Up @@ -79,6 +80,16 @@ fi
bashio::log.info "Activating venv"
. "$VENV_PATH/bin/activate"

#
# Install Python packages
#

if [ -n "${PIP}" ]; then
bashio::log.info "Installing extra PYTHON packages: $PIP"
su "$USER" \
-c "pip install $PIP"
fi

# Everything below should be kept in sync with
# core:rootfs/etc/services.d/home-assistant/run
# from upstream:
Expand All @@ -93,3 +104,4 @@ bashio::log.info "Starting homeassistant"
exec \
s6-setuidgid "$USER" \
python3 -m homeassistant --config "$CONFIG_PATH"