I want to use variables in my compose file for settings and already have a working snippet to update my settings from configure_host.
What I am currently wondering about: does UCS take care of doing a docker-compose up -d when settings have changed or do I need to do that in configure_host.
PS: is it normal that the docker-compose files are not cleaned up after app removal?
edit: so far none the compose based apps have docker-compose in their configure_hosts scripts, so I am doing some tests without this explicit reload as well.
A full reinitialisation is going a bit too far for my case (since this then also seems to pull new containers) and therefore takes some moments to complete. What I am looking to do is exploit normal docker-compose behaviour.
Let me give you an example.
In you docker-compose.yml you can work with variables. so that you for example have something like the following:
So instead of putting the value for MYSQL_USER into the compose file itself I am specifying storing them in a file called .env. When you call docker-compose from the directory this .env file is stored it will read out the file and use them for the actual run of the compose file.
The nice thing is that if I now need to change setting, I am just updating my .env and call docker-compose up -d again. This will check where the changed config has been used (and which containers depend on containers with changed values) and only “recreate” those.
That is usually a quick transaction.
But I guess I could just reuse your snippet and instead of calling reinitialize, I’d call docker-compose directly. This would then prevent the command running already during installation of the app.
Yes, it may not pull (I thought I’ve seen it when writing my initial response, but I did not recheck this meanwhile), but still a reinitialize is a bit heavy for my use as it recreates all containers in the compose file, while a docker-compose up -d in my above example would only recreate containers which configuration has changed.