Description
How I run localdeck-config and esphome in docker containers for use with a dockerised Home Assistant
Writing this up here a rough guide of how I've currently got this setup and running in the hope it provides value to others wanting to do the same, or as a guide to what the current difficulties are with doing the same.
My setup uses a docker-compose file to spin up Home Assistant, EspHome, and the Localdeck Configurator on my local server dell01
.
For documenting this here I've stripped out nginx and anything not relevant to the 3 containers above.
Everything is running on the default ports as below:
- Home Assistant: 8123
- Esphome: 6052
- Localdeck Configurator: 3000
The setup works by overriding the run.sh
file used as the startup file of the localdeck configurator, and overriding enough variables to point everything to where we expect.
Home Assistant and EspHome volumes are mapped to physical locations on the machine, and then the localdeck configurator is mapped to the same files on the host.
With this setup I'm able to visit each app at the below urls and everything seems to work (HA already worked. ESPHome works. Configurator works and pulls data from HA)
- Home Assistant: http://dell01:8123
- EspHome: http://dell01:6052
- Configurator: http://dell01:3000/
Run.sh file:
#!/usr/bin/with-contenv bashio
set +u
export NUXT_FILES_DIR="/homeassistant/esphome"
#What is the public url of the configurator?
export NUXT_PUBLIC_BASE_URL="http://dell01:3000"
export NUXT_APP_BUILD_ASSETS_DIR="/_nuxt"
#Where can the configurator reach HA?
export NUXT_API_URL="http://host.docker.internal:8123/api"
#Long lived token from HA
export NUXT_API_TOKEN="REDACTED"
echo "Starting app with custom run.sh file"
node ./server/index.mjs
Docker-Compose file:
version: '3'
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:latest"
volumes:
- ./config:/config
- /etc/localtime:/etc/localtime:ro
- /var/run/dbus:/run/dbus:ro
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
restart: unless-stopped
privileged: true
network_mode: host
extra_hosts:
- "host.docker.internal:host-gateway"
esphome:
container_name: esphome
image: "esphome/esphome:latest"
volumes:
- ./esphome:/config
restart: unless-stopped
network_mode: host
extra_hosts:
- "host.docker.internal:host-gateway"
configurator:
container_name: localdeck_configurator
#Please don't use random images in your environment, I'm intentionally on the latest to test this out
image: ghcr.io/localbytes/hass-localdeck-configurator-amd64:0.2-51-g9f19cdb
ports:
- "3000:3000"
volumes:
- ./esphome:/homeassistant/esphome
- ./config/configuration.yaml:/config/configuration.yaml
- ./run.sh:/usr/src/app/run.sh
extra_hosts:
- "host.docker.internal:host-gateway"