Skip to content

Commit

Permalink
Update devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed May 12, 2024
1 parent b5f77f0 commit 8ccec8e
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 95 deletions.
5 changes: 1 addition & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
ARG BUILD_FROM BUILD_FROM_TAG
FROM python:3.12-slim
FROM homeassistant/home-assistant:dev

ENV DEVCONTAINER=true

COPY ./container /container
COPY ./install /install

ARG OS_VARIANT CONTAINER_TYPE
RUN \
bash /install/init.sh \
&& bash /install/container.sh \
&& bash /install/integration.sh \
&& bash /install/cleanup.sh

CMD ["bash"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck source=/dev/null

source /opt/container/helpers/common/paths.sh
source /opt/container/helpers/paths.sh
mkdir -p /config

if test -f "$(workspacePath)config/configuration.yaml"; then
Expand All @@ -22,12 +22,12 @@ fi
if test -d "$(workspacePath)custom_components"; then
echo "Symlink the custom component directory"

if test -d "$(workspacePath)custom_components"; then
if test -d "/config/custom_components"; then
rm -R /config/custom_components
fi

ln -sf "$(workspacePath)custom_components/" /config/custom_components || echo "Could not copy the custom_component" exit 1
elif test -f "__init__.py"; then
elif test -f "__init__.py"; then
echo "Having the component in the root is currently not supported"
fi

Expand Down
21 changes: 0 additions & 21 deletions .devcontainer/container/helpers/integration/init.sh

This file was deleted.

File renamed without changes.
16 changes: 8 additions & 8 deletions .devcontainer/container/makefiles/integration.mk
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
start: ## Start Home Assistant with the integration loaded
@bash /opt/container/helpers/common/homeassistant/start.sh
@bash /opt/container/helpers/homeassistant/start.sh

run:
start

up:
start

set-version: ## Set Home Assistant version
@bash /opt/container/helpers/common/homeassistant/set-version.sh
@bash /opt/container/helpers/homeassistant/set-version.sh

install: ## Install Home Assistant dev in the container
@python3 -m pip --disable-pip-version-check install --upgrade git+https://github.com/home-assistant/home-assistant.git@dev

upgrade: ## Upgrade Home Assistant to latest dev in the container
install

run:
start

check-config: ## Check Home Assistant config
@hass -c /config --script check_config

init: ## Initialize the dev env
@bash /opt/container/helpers/integration/init.sh
1 change: 0 additions & 1 deletion .devcontainer/install/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

echo -e "\\033[0;34mRunning cleanup script 'cleanup.sh'\\033[0m"

apt-get clean -y
rm -fr /var/lib/apt/lists/*
rm -fr /tmp/* /var/{cache,log}/*

Expand Down
10 changes: 4 additions & 6 deletions .devcontainer/install/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ echo -e "\\033[0;34mRunning install script 'container.sh'\\033[0m"

export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install -y --no-install-recommends \
make
apk add --no-cache \
make \
git

mkdir -p /opt/container/makefiles
mkdir -p /opt/container/helpers
touch /opt/container/makefiles/dummy.mk

cp /container/container.mk /opt/container/container.mk
cp -r /container/helpers/common /opt/container/helpers/common
cp -r /container/helpers /opt/container/helpers

cp /container/container /usr/bin/container
chmod +x /usr/bin/container

cp /container/makefiles/integration.mk /opt/container/makefiles/integration.mk
cp -r /container/helpers/integration /opt/container/helpers/integration

container help
47 changes: 0 additions & 47 deletions .devcontainer/install/integration.sh

This file was deleted.

6 changes: 1 addition & 5 deletions scripts/devcontainer
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ if ! ${docker} ps -a | grep -wq ${container} && [[ "${cmd}" != "down" ]]; then
${docker} create -it --name "${container}" -p "${port}" -v "${volume}" "${image}"

docker_start

log.info "Initialize container..."
${docker} exec -it -w "${workdir}" "${container}" container install
bootstrap "install"
fi

if [[ "${cmd}" == "menu" ]]; then
Expand Down Expand Up @@ -143,7 +139,7 @@ case "${cmd}" in
docker_start
fi
log.info "Send command '${cmd}' to container..."
if [[ "${cmd}" == "start" ]]; then
if [[ "${cmd}" == "start" || "${cmd}" == "up" || "${cmd}" == "run" ]]; then
log.info "Note: After Home Assistant initialization you can access to system on http://localhost:9123/"
fi
${docker} exec -it -w "${workdir}" "${container}" container "${cmd}"
Expand Down

0 comments on commit 8ccec8e

Please sign in to comment.