Open malhusseiny opened 6 months ago
The logic that parses the Docker configuration for MongoDB is here: https://github.com/symfony-cli/symfony-cli/blob/main/envs/docker.go#L401 and the logic to use that information to create env vars is here: https://github.com/symfony-cli/symfony-cli/blob/main/envs/docker.go#L401
As I'm not a MongoDB user myself, I'm not sure what should be changed there. @malhusseiny Can you help me?
@fabpot
Here is the line that needs to be changed: https://github.com/symfony-cli/symfony-cli/blob/main/envs/envs.go#L242
In order to create the correct MONGODB_URL
env var, it should be changed to:
values[fmt.Sprintf("%sURL", prefix)] = fmt.Sprintf("%s://%s:%s@%s:%s", endpoint["scheme"].(string), endpoint["username"].(string), endpoint["password"].(string), endpoint["host"].(string), formatInt(endpoint["port"]))
such that the value of endpoint["path"]
(i.e. default working database) is not incorrectly set as authentication database (the one where MongoDB looks up the connection login credentials). This is also consistent with with intended purpose of the MONGO_INITDB_DATABASE
docker environment variable as per the official mongo docker image.
But here, you've completely removed the "path", which looks wrong to me. But then again, I'm not a MongoDB user, so ideally, I'd like others to chime in here. As a first step, maybe you can create a PR for that change?
@fabpot Absolutely! Please check out my justification in the PR #458
A MongoDB service with the following docker-compose configuration in
compose.yml
:causes the variables
MONGO_DATABASE
,MONGO_DB
,MONGO_NAME
to be set tosymfony
, which is fine. However, it also sets theauthSource
param ofMONGO_URL
tosymfony
as shown below:Without the
MONGO_INITDB_DATABASE: ${MONGODB_DB:-symfony}
in the docker compose file, all database-related environment variables as well as theauthSource
param become empty. It would be great if you could untangle that coupling.