Open i8beef opened 1 year ago
Hi,
I am trying to set up the docker container, including the above command, but I think that it is not possible to mount a single file using the -v
flag (it should only be used for directories). Even ChatGPT said:
The -v option in the docker run command is used to mount volumes, not individual files. When you use the -v option, you specify a volume in the format host-path:container-path. This mounts the entire directory from the host into the container.
The actual problem I am facing is that even if I add the above line on the docker run
command, I get the default config file loaded, which I can tell from the MQTT client not being connected nor the WebUI password changing.
ChatGPT is wrong... but your file has to already exist to do this, or else it will DEFAULT to it being a directory named "appsettings.Production.json" when its not. Do you already have an appsettings.Production.json file in place that you are trying to mount INTO the container?
Yes, I figured out that ChatGPT is wrong. -v
can be used for both volume and file mounts it seems. Yes I have the file in place. When I use the absolute path in the -v command I get the following error on the log of the container:
Failed to load configuration from file '/app/appsettings.Production.json'.
When I use the relative path (i.e. exactly as it is on the first comment), the container starts without errors but the default configuration is loaded, as I described on my previous comment.
Loaded with configuration from: appsettings.json, /app/appsettings.Production.json
I recommend always using a full path for the left side of the -v
argument, it removes possible failure potentials when you are moving stuff around. Example, this is the exact argument from my own setup: -v /srv/homeautio.mqtt.googlehome/appsettings.Production.json:/app/appsettings.Production.json:ro
As long as your file isn't empty and is a valid JSON structure, it should attempt to read it. Did you pull the default appsettings.json (https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/blob/master/src/HomeAutio.Mqtt.GoogleHome/appsettings.json) as a starting point? Have you made sure its valid, ie, pass it through a JSON parser?
Shoot, I had missed a "
in the configuration file. So sorry for not seeing that earlier!
With the 3.0 branch, upgrading changed some of how the configuration is wired up.
appsettings.Production.json
now needs to exist at the ROOT of the application instead of in theconfig
directory. This lets me lean into some defaults in the new upgraded framework setups, and brings everything inline with other .NET apps.Existing docker setups can convert over by just adding an explicit mount for the file at
/app/appsettings.Production.json
like this:Everything else should stay the same, but this is a large upgrade, so please report any oddities you run across!