You mount your host folder /var/lib/z2m-test into the container as /var/lib/gladysassistant
Then you tell Gladys to work with /var/lib/gladysassistant, which it does when it creates the Mosquito and Z2M configuration files. That’s why you find the configuration files in /var/lib/z2m-test on your host.
When Gladys creates the other containers (Mosquito and Z2M), it uses the SQLITE_FILE_PATH variable to mount the volumes. So the /var/lib/gladysassistant of your host… That’s where it doesn’t work. I don’t know how to detect that /var/lib/gladysassistant is actually a mount of /var/lib/z2m-test.
The configuration files should be written by Gladys somewhere on your host. I decided to use SQLITE_FILE_PATH as the folder where to write these files. But without thinking about the case where you mount this folder from another path on your host.
But maybe we should use another variable for this? Like HOST_PATH_Z2M_FILES?
I disagree, all the images I’ve used so far allow you to use a different persistence path than the official one.
The real issue we have here is having to specify multiple paths if we use an alternative path.
Do we really need to specify a path for the database, can’t we simply put all the files within the container in the same folder, here surely /var/lib/gladysassistant, thus set the value of the SQLITE_FILE_PATH (and therefore remove it from the config) and then simply ask the user to fill in the value PERSISTANCE_FOLDER (for example) which would map between the container folder and the host?
Here we are in a case where if we want to test several gladys images, we have to modify all the config paths, the SQLITE_FILE_PATH then the folder in the container and the mapping folder on the host.
Indeed, everything is working well now. It’s true that, as my message above indicates, we had to change three values to do this, but all the issues are resolved.
The two types of Aquara devices I have are working well, the file paths have been modified correctly, and the information is being uploaded to the dashboard as it should. Kudos to everyone who worked on this integration.
Relis moi, j’ai pas dit que techniquement c’était pas possible. J’ai juste dit qu’on ne peut pas exploser toutes les instances de gladys en production. Car faire ce changement ça pète tout.
Exact specific case, not in production. The command from @cicoub13 works perfectly because all the paths match.
Why not just do like the port exposure with Docker?
For example, by default an application starts on port 3456, but you want to expose port 80 publicly, then you use the option -p 80:3456.
For me, the same should be done in Gladys: everything is stored in the container by default in /var/lib/gladysassistant and the path modification goes through the modification of the container path: -v /data/exemple/Gladys:/var/lib/gladysassistant.
Oh, that’s the case for Gladys, the problem is not there.
It would be necessary to be able to retrieve the bind (-v) from the container to communicate it to other containers. If we manage that, it will solve everything.
Goal: retrieve the bind from the container on /var/lib/gladysassistant
@cicoub13 I just quickly tested a small piece of js with the lib we use without going all the way.
var Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
// HERE we can replace gladys with os.hostname
var container = docker.getContainer('gladys');
container.inspect(function (err, data) {
var string = JSON.stringify(data);
var objectValue = JSON.parse(string);
console.log(objectValue['HostConfig']['Binds']);
});
Not bad. I like the idea. But how do I get the right one? Since you can mount any folder from the host and any folder in Docker (with SQLITE_FILE_PATH).
And even mount multiple folders.
Gladys, in any case (for the MQTT and Zigbee part), must write its config in /var/lib/gladysassystant, that’s in the container.
By recovering the bind on the host side, we can use it to create other containers and manage persistence.
My previous post is not a good example because I bind the same path. But for example, if I take the case of @Albenss
@VonOx that seems like a good solution to me Indeed, this would avoid forcing the user to put this data in /var/lib/gladysassistant on the host if they don’t have that folder available.
The only remark is that on the JS side, you’ll need to run the regex with the basePath and not /var/lib/gladysassistant, and we’ll be good to go!
@cicoub13 are you integrating this into the Zigbee2mqtt PR?
Apart from that, I’m good to merge the zigbee2mqtt PR, I saw your video @cicoub13 and it’s amazing! It’s really great work, nothing to say Congrats to everyone who worked on this PR, it’s amazing!
Internally, it should always be /var/lib/gladysassistant. (standard to be defined)
This variable (SQLITE_FILE_PATH) must be set by default in the image with this path.
Here we need to manage this variable (used only for the database) and the persistence bind.
For creating service containers, only the host bind matters, it doesn’t matter where the database is in the container.
There are 2 topics:
How to manage gladys « data » in the image → /var/lib/gladysassistant as standard
How to create service containers that use the same host bind path as gladys → the function I propose (/???/??? bound to /var/lib/gladysassistant)