deconz-community / deconz-docker

MIT License
376 stars 34 forks source link

Feature request: Make appdata parameter configurable via environment variable #232

Closed snozzlebert closed 8 months ago

snozzlebert commented 8 months ago

Script currently contains several options that are configurable using environment variables. However, appdata is not one of them. It would be nice if DECONZ_APPDATA_DIR variable or something like that to be able to use another volume binding.

DECONZ_OPTS="--auto-connect=1 \
        --appdata=/opt/deCONZ 
phdelodder commented 8 months ago

You can use the volume to have a different directory, why would you move it within the docker container?

snozzlebert commented 8 months ago

Good question. I would like to use this image in Home Assistant OS instead of the provided addon by Home Assistant. Because this one is better maintained. It is not possible to control the volume bindings of docker containers in Home Assistant OS. The persistant data directory is mounted as /data in the container.

My alternative would be to create a custom images with this as a base image and replace all /opt/deCONZ with /data in start.sh. With a variable for /opt/deCONZ I don't have to rebuild/extend the image.

phdelodder commented 8 months ago

I can look into making a dev build for you to test.

phdelodder commented 8 months ago

I have created a dev image, can you verify if the change is sufficient for you purposes?

snozzlebert commented 8 months ago

No, I think all occurrences of /opt/deCONZ in start.sh should be replaced by $DECONZ_APPDATA_DIR Then also the VNC config etc. will be stored in the right location.

phdelodder commented 8 months ago

Modified it.

snozzlebert commented 8 months ago

I can confirm it works for my use case. Thanks! I tested this with the following config.yaml in local add-on repository in Home Assistant OS (for those who are interested):

version: dev
name: deCONZ
slug: deconz
description: >-
  Control a Zigbee network with ConBee or RaspBee by Dresden Elektronik.
url: https://github.com/deconz-community/deconz-docker
image: ghcr.io/deconz-community/deconz-docker
apparmor: false
arch:
  - amd64
  - aarch64
backup_exclude:
  - "*/otau"
devices:
  - /dev/mem
discovery:
  - deconz
gpio: true
homeassistant: 0.91.2
init: false
kernel_modules: true
environment:
  TZ: "Europe/Amsterdam"
  DECONZ_WEB_PORT: "40850"
  DECONZ_WS_PORT: "8081"
  DECONZ_VNC_MODE: "1"
  DECONZ_NOVNC_PORT: "0"
  DECONZ_UPNP: "0"
  DECONZ_VNC_PASSWORD_FILE: "<remove>"
  DECONZ_APPDATA_DIR: /data
map:
  - addon_config:rw
ports:
  40850/tcp: null
  5900/tcp: null
  8081/tcp: null
privileged:
  - SYS_RAWIO
startup: services
udev: true
usb: true

I tested deCONZ and VNC on port 5900 (via RealVNC Viewer). Didn't test noVNC, because I don't use it.

phdelodder commented 8 months ago

I'll merge the PR when there is a new beta

phdelodder commented 8 months ago

Merged