t0bst4r / matterbridge-home-assistant

Apache License 2.0
86 stars 11 forks source link

Enhancement: Load config file from within container (not docker env) #66

Closed tam481 closed 3 months ago

tam481 commented 3 months ago

@t0bst4r Many thanks for working on loading the config file externally. Doing so in the docker environment variable forces the container to be recreated every time the config is modified. Please could I request that this is enhanced so that the config file is loaded within the container itself so that it is reloaded upon simply restarting the container or better still have an option to automatically reload the config file every so many minutes etc :-)

Also, do you know if the current method is supported in docker compose? I can't seem to get it to work because it's throwing the following error: "unexpected character "{" in variable name "{""

t0bst4r commented 3 months ago

Doing so in the docker environment variable forces the container to be recreated every time the config is modified. Please could I request that this is enhanced so that the config file is loaded within the container itself so that it is reloaded upon simply restarting the container

I don’t get what you mean here. The config file is loaded in the docker-entrypoint.sh script which is executed everytime the docker container starts (or restarts). The CONFIG_FILE variable is only pointing to the location where you mount your config file. The variable only needs to be changed (and therefore the docker container needs to be recreated) if you rename the config file. But when the content of the config file changes, it should be enough to restart the docker container.

While I am writing this message, one thing came to my mind: what do you mean with "restart" ? Are you really restarting the docker container, or do you click the restart button in the matterbridge-ui?

Maybe I’ll do another change to load the config from within the app itself (as you requested) to get more consistency (for example when the user clicks on the restart button in the UI).

Also, do you know if the current method is supported in docker compose? I can't seem to get it to work because it's throwing the following error: "unexpected character "{" in variable name "{""

Yes, it is. I am running it with compose. Can you provide your exact docker-compose.yaml?

tam481 commented 3 months ago

I think I may have misunderstood the documentation. Here's my docker-compose.yaml file

  matterbridge:
    image: ghcr.io/t0bst4r/matterbridge-home-assistant:latest
    restart: always
    volumes:
      - "$PWD/../conf/matterbridge:/config:ro"
      - "$PWD/../data/matterbridge:/root/.matterbridge"
    network_mode: host
    environment:
     - CONFIG_FILE="/config/config.json"
tam481 commented 3 months ago

I'm guessing the issue I'm having now that the config file is being specified correctly is related to issue #67

t0bst4r commented 3 months ago

Fixed with #67