Hello!
I’ve ran into an odd problem with the Nextcloud community container recently. Version: 29.0.8/29.0.11
I’m deploying multiple configuration files into the container image during the build process.
These files are sometimes hardcoded or read custom env variables to configure, for example, the OIDC plugin.
On both my test environment and my local machine, this approach works well.
And then there’s the production machine.
For some strange reason, during Nextcloud’s installation by the container, all my configuration files are merged into the main config.php, with the env(...) calls replaced with their actual values.
This behaviour is weird and inconsistant but wouldn’t prevent the container from working if it was the only weird thing happening.
The breaking problem:
Some env variables are ignored while others are honored:
Honored:
my custom env variables for OIDC config
NEXTCLOUD_ADMIN_USER & NEXTCLOUD_ADMIN_PASSWORD
other nextcloud variables like NEXTCLOUD_TRUSTED_DOMAINS
Ignored:
All env variables related to the reverse proxy
All database configuration variables (database connection still works, through some dark magic I have yet to identify)
All of this tells me I missed something in my deployment or in the docker container’s behaviour but I can’t pinpoint it
I can, however, tell you a few things it is not:
a lingering volume (I take care of destroying / cleaning everything between each test)
an accidental deployment from my part (no such file is sent into the container and the database password is different each time)
non-included env vars (they are all listed in the container details with the expected values)
the usual behaviour of the container (works on my machine™)
Ignored how? As in not visible in your config/config.php or as in not visible in occ config:list system (which are very different)? See Nextcloud Docker: Viewing the config.
All env variables related to the reverse proxy
RP config is is loaded via the config/reverse-proxy.config.php that is built into the image every time the container starts.
All database configuration variables (database connection still works, through some dark magic I have yet to identify)
DB configuration is install-time (one-time) only (at least when provided via environment variables).
In any case, we can’t do more than guess unless you provide:
your Compose file
details regarding your customization
your merged config (occ config:list system)
steps you’re using to reproduce the behavior
Keep in mind that restarts are not sufficient to inject environment variable changes in Docker. You must recreate containers.
For some strange reason, during Nextcloud’s installation by the container, all my configuration files are merged into the main config.php, with the env(...) calls replaced with their actual values.
This is expected behavior, since the installer creates the initial config/config.php based on the real-time full configuration at install time. However, any secondary config files in config/ will still take priority over config/config.php.
Ignored as in not visible in the config.php nor through occ config:list system.
Very good point! It seems no default *.config.php is present in the config directory.
I am aware. I remove, rebuild and recreate for each test
I may have been unclear: the contents of my custom made *.config.php files are being merged into config.php which does not happen on any other deployment I run.
Then again, none of the default *.config.php files are present, so I know where to investigate now.
Here are my compose.yml and Dockerfile, for reference:
No idea why you don’t have them, but maybe they got dropped during some of your development or something? You likely have warnings in the container logs about this. You can manually update/deploy them using the process documented here for the warnings about outdated config files.
I changed my Dockerfile to copy my *.config.php files to an arbitrary directory to leave nextcloud’s directory empty and then copy them over with a post-installation hook.
This solved the disappearance of nextcloud’s *.config.php files and the instance is running smoothly
Many thanks for pulling my head out of the water!
A few oddities remain though:
the database user/password are still wrong yet functional (both in the file and through occ config:list system)
the config.php file is still merging all the *.config.php files despite not doing this on other machines using the same version of the container