Fix Bitnami MongoDB environment variables for Docker Compose

Fixes gh-41097
This commit is contained in:
Scott Frederick 2024-06-13 11:09:52 -05:00
parent 4e3d1a67d7
commit 7d96789869
3 changed files with 7 additions and 6 deletions

View File

@ -41,9 +41,9 @@ class MongoEnvironment {
"MONGO_INITDB_ROOT_USERNAME_FILE is not supported");
Assert.state(!env.containsKey("MONGO_INITDB_ROOT_PASSWORD_FILE"),
"MONGO_INITDB_ROOT_PASSWORD_FILE is not supported");
this.username = env.getOrDefault("MONGO_INITDB_ROOT_USERNAME", env.get("MONGO_ROOT_USERNAME"));
this.password = env.getOrDefault("MONGO_INITDB_ROOT_PASSWORD", env.get("MONGO_ROOT_PASSWORD"));
this.database = env.get("MONGO_INITDB_DATABASE");
this.username = env.getOrDefault("MONGO_INITDB_ROOT_USERNAME", env.get("MONGODB_ROOT_USERNAME"));
this.password = env.getOrDefault("MONGO_INITDB_ROOT_PASSWORD", env.get("MONGODB_ROOT_PASSWORD"));
this.database = env.getOrDefault("MONGO_INITDB_DATABASE", env.get("MONGODB_DATABASE"));
}
String getUsername() {

View File

@ -46,7 +46,7 @@ class MongoBitnamiDockerComposeConnectionDetailsFactoryIntegrationTests extends
assertThat(connectionString.getCredential().getUserName()).isEqualTo("root");
assertThat(connectionString.getCredential().getPassword()).isEqualTo("secret".toCharArray());
assertThat(connectionString.getCredential().getSource()).isEqualTo("admin");
assertThat(connectionString.getDatabase()).isEqualTo("test");
assertThat(connectionString.getDatabase()).isEqualTo("testdb");
assertThat(connectionDetails.getGridFs()).isNull();
}

View File

@ -4,5 +4,6 @@ services:
ports:
- '27017'
environment:
- 'MONGO_ROOT_USERNAME=root'
- 'MONGO_ROOT_PASSWORD=secret'
- 'MONGODB_ROOT_USERNAME=root'
- 'MONGODB_ROOT_PASSWORD=secret'
- 'MONGODB_DATABASE=testdb'