Skip to content

Commit 09a6ae5

Browse files
Add support for Bitnami container images with Docker Compose
Closes gh-35759
1 parent 533f6c3 commit 09a6ae5

File tree

50 files changed

+993
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+993
-65
lines changed

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/cassandra/CassandraDockerComposeConnectionDetailsFactory.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,10 +32,12 @@
3232
class CassandraDockerComposeConnectionDetailsFactory
3333
extends DockerComposeConnectionDetailsFactory<CassandraConnectionDetails> {
3434

35+
private static final String[] CASSANDRA_CONTAINER_NAMES = { "cassandra", "bitnami/cassandra" };
36+
3537
private static final int CASSANDRA_PORT = 9042;
3638

3739
CassandraDockerComposeConnectionDetailsFactory() {
38-
super("cassandra");
40+
super(CASSANDRA_CONTAINER_NAMES);
3941
}
4042

4143
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/cassandra/CassandraEnvironment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ class CassandraEnvironment {
2828
private final String datacenter;
2929

3030
CassandraEnvironment(Map<String, String> env) {
31-
this.datacenter = env.getOrDefault("CASSANDRA_DC", "datacenter1");
31+
this.datacenter = env.getOrDefault("CASSANDRA_DC", env.getOrDefault("CASSANDRA_DATACENTER", "datacenter1"));
3232
}
3333

3434
String getDatacenter() {

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/elasticsearch/ElasticsearchDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,14 +31,17 @@
3131
* @author Moritz Halbritter
3232
* @author Andy Wilkinson
3333
* @author Phillip Webb
34+
* @author Scott Frederick
3435
*/
3536
class ElasticsearchDockerComposeConnectionDetailsFactory
3637
extends DockerComposeConnectionDetailsFactory<ElasticsearchConnectionDetails> {
3738

39+
private static final String[] ELASTICSEARCH_CONTAINER_NAMES = { "elasticsearch", "bitnami/elasticsearch" };
40+
3841
private static final int ELASTICSEARCH_PORT = 9200;
3942

4043
protected ElasticsearchDockerComposeConnectionDetailsFactory() {
41-
super("elasticsearch");
44+
super(ELASTICSEARCH_CONTAINER_NAMES);
4245
}
4346

4447
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mariadb/MariaDbEnvironment.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
* @author Moritz Halbritter
2828
* @author Andy Wilkinson
2929
* @author Phillip Webb
30+
* @author Scott Frederick
3031
*/
3132
class MariaDbEnvironment {
3233

@@ -52,7 +53,7 @@ private String extractPassword(Map<String, String> env) {
5253
Assert.state(!env.containsKey("MYSQL_RANDOM_ROOT_PASSWORD"), "MYSQL_RANDOM_ROOT_PASSWORD is not supported");
5354
Assert.state(!env.containsKey("MARIADB_ROOT_PASSWORD_HASH"), "MARIADB_ROOT_PASSWORD_HASH is not supported");
5455
boolean allowEmpty = env.containsKey("MARIADB_ALLOW_EMPTY_PASSWORD")
55-
|| env.containsKey("MYSQL_ALLOW_EMPTY_PASSWORD");
56+
|| env.containsKey("MYSQL_ALLOW_EMPTY_PASSWORD") || env.containsKey("ALLOW_EMPTY_PASSWORD");
5657
String password = env.get("MARIADB_PASSWORD");
5758
password = (password != null) ? password : env.get("MYSQL_PASSWORD");
5859
password = (password != null) ? password : env.get("MARIADB_ROOT_PASSWORD");

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mariadb/MariaDbJdbcDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@
2929
* @author Moritz Halbritter
3030
* @author Andy Wilkinson
3131
* @author Phillip Webb
32+
* @author Scott Frederick
3233
*/
3334
class MariaDbJdbcDockerComposeConnectionDetailsFactory
3435
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
3536

37+
private static final String[] MARIADB_CONTAINER_NAMES = { "mariadb", "bitnami/mariadb" };
38+
3639
protected MariaDbJdbcDockerComposeConnectionDetailsFactory() {
37-
super("mariadb");
40+
super(MARIADB_CONTAINER_NAMES);
3841
}
3942

4043
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mariadb/MariaDbR2dbcDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,12 +31,15 @@
3131
* @author Moritz Halbritter
3232
* @author Andy Wilkinson
3333
* @author Phillip Webb
34+
* @author Scott Frederick
3435
*/
3536
class MariaDbR2dbcDockerComposeConnectionDetailsFactory
3637
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
3738

39+
private static final String[] MARIADB_CONTAINER_NAMES = { "mariadb", "bitnami/mariadb" };
40+
3841
MariaDbR2dbcDockerComposeConnectionDetailsFactory() {
39-
super("mariadb", "io.r2dbc.spi.ConnectionFactoryOptions");
42+
super(MARIADB_CONTAINER_NAMES, "io.r2dbc.spi.ConnectionFactoryOptions");
4043
}
4144

4245
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoDockerComposeConnectionDetailsFactory.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,10 +34,12 @@
3434
*/
3535
class MongoDockerComposeConnectionDetailsFactory extends DockerComposeConnectionDetailsFactory<MongoConnectionDetails> {
3636

37+
private static final String[] MONGODB_CONTAINER_NAMES = { "mongo", "bitnami/mongodb" };
38+
3739
private static final int MONGODB_PORT = 27017;
3840

3941
protected MongoDockerComposeConnectionDetailsFactory() {
40-
super("mongo", "com.mongodb.ConnectionString");
42+
super(MONGODB_CONTAINER_NAMES, "com.mongodb.ConnectionString");
4143
}
4244

4345
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mongo/MongoEnvironment.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
* @author Moritz Halbritter
2727
* @author Andy Wilkinson
2828
* @author Phillip Webb
29+
* @author Scott Frederick
2930
*/
3031
class MongoEnvironment {
3132

@@ -40,8 +41,8 @@ class MongoEnvironment {
4041
"MONGO_INITDB_ROOT_USERNAME_FILE is not supported");
4142
Assert.state(!env.containsKey("MONGO_INITDB_ROOT_PASSWORD_FILE"),
4243
"MONGO_INITDB_ROOT_PASSWORD_FILE is not supported");
43-
this.username = env.get("MONGO_INITDB_ROOT_USERNAME");
44-
this.password = env.get("MONGO_INITDB_ROOT_PASSWORD");
44+
this.username = env.getOrDefault("MONGO_INITDB_ROOT_USERNAME", env.get("MONGO_ROOT_USERNAME"));
45+
this.password = env.getOrDefault("MONGO_INITDB_ROOT_PASSWORD", env.get("MONGO_ROOT_PASSWORD"));
4546
this.database = env.get("MONGO_INITDB_DATABASE");
4647
}
4748

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mysql/MySqlEnvironment.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
* @author Moritz Halbritter
2828
* @author Andy Wilkinson
2929
* @author Phillip Webb
30+
* @author Scott Frederick
3031
*/
3132
class MySqlEnvironment {
3233

@@ -44,7 +45,7 @@ class MySqlEnvironment {
4445

4546
private String extractPassword(Map<String, String> env) {
4647
Assert.state(!env.containsKey("MYSQL_RANDOM_ROOT_PASSWORD"), "MYSQL_RANDOM_ROOT_PASSWORD is not supported");
47-
boolean allowEmpty = env.containsKey("MYSQL_ALLOW_EMPTY_PASSWORD");
48+
boolean allowEmpty = env.containsKey("MYSQL_ALLOW_EMPTY_PASSWORD") || env.containsKey("ALLOW_EMPTY_PASSWORD");
4849
String password = env.get("MYSQL_PASSWORD");
4950
password = (password != null) ? password : env.get("MYSQL_ROOT_PASSWORD");
5051
Assert.state(StringUtils.hasLength(password) || allowEmpty, "No MySQL password found");

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mysql/MySqlJdbcDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@
2929
* @author Moritz Halbritter
3030
* @author Andy Wilkinson
3131
* @author Phillip Webb
32+
* @author Scott Frederick
3233
*/
3334
class MySqlJdbcDockerComposeConnectionDetailsFactory
3435
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
3536

37+
private static final String[] MYSQL_CONTAINER_NAMES = { "mysql", "bitnami/mysql" };
38+
3639
protected MySqlJdbcDockerComposeConnectionDetailsFactory() {
37-
super("mysql");
40+
super(MYSQL_CONTAINER_NAMES);
3841
}
3942

4043
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/mysql/MySqlR2dbcDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,12 +31,15 @@
3131
* @author Moritz Halbritter
3232
* @author Andy Wilkinson
3333
* @author Phillip Webb
34+
* @author Scott Frederick
3435
*/
3536
class MySqlR2dbcDockerComposeConnectionDetailsFactory
3637
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
3738

39+
private static final String[] MYSQL_CONTAINER_NAMES = { "mysql", "bitnami/mysql" };
40+
3841
MySqlR2dbcDockerComposeConnectionDetailsFactory() {
39-
super("mysql", "io.r2dbc.spi.ConnectionFactoryOptions");
42+
super(MYSQL_CONTAINER_NAMES, "io.r2dbc.spi.ConnectionFactoryOptions");
4043
}
4144

4245
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/neo4j/Neo4jDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,11 +30,14 @@
3030
* for a {@code Neo4j} service.
3131
*
3232
* @author Andy Wilkinson
33+
* @author Scott Frederick
3334
*/
3435
class Neo4jDockerComposeConnectionDetailsFactory extends DockerComposeConnectionDetailsFactory<Neo4jConnectionDetails> {
3536

37+
private static final String[] NEO4J_CONTAINER_NAMES = { "neo4j", "bitnami/neo4j" };
38+
3639
Neo4jDockerComposeConnectionDetailsFactory() {
37-
super("neo4j");
40+
super(NEO4J_CONTAINER_NAMES);
3841
}
3942

4043
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/neo4j/Neo4jEnvironment.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,13 +25,18 @@
2525
* Neo4j environment details.
2626
*
2727
* @author Andy Wilkinson
28+
* @author Scott Frederick
2829
*/
2930
class Neo4jEnvironment {
3031

3132
private final AuthToken authToken;
3233

3334
Neo4jEnvironment(Map<String, String> env) {
34-
this.authToken = parse(env.get("NEO4J_AUTH"));
35+
AuthToken authToken = parse(env.get("NEO4J_AUTH"));
36+
if (authToken == null && env.containsKey("NEO4J_PASSWORD")) {
37+
authToken = parse("neo4j/" + env.get("NEO4J_PASSWORD"));
38+
}
39+
this.authToken = authToken;
3540
}
3641

3742
private AuthToken parse(String neo4jAuth) {

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/postgres/PostgresEnvironment.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
* @author Moritz Halbritter
2828
* @author Andy Wilkinson
2929
* @author Phillip Webb
30+
* @author Scott Frederick
3031
*/
3132
class PostgresEnvironment {
3233

@@ -37,14 +38,14 @@ class PostgresEnvironment {
3738
private final String database;
3839

3940
PostgresEnvironment(Map<String, String> env) {
40-
this.username = env.getOrDefault("POSTGRES_USER", "postgres");
41+
this.username = env.getOrDefault("POSTGRES_USER", env.getOrDefault("POSTGRESQL_USER", "postgres"));
4142
this.password = extractPassword(env);
42-
this.database = env.getOrDefault("POSTGRES_DB", this.username);
43+
this.database = env.getOrDefault("POSTGRES_DB", env.getOrDefault("POSTGRESQL_DB", this.username));
4344
}
4445

4546
private String extractPassword(Map<String, String> env) {
46-
String password = env.get("POSTGRES_PASSWORD");
47-
Assert.state(StringUtils.hasLength(password), "No POSTGRES_PASSWORD defined");
47+
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD"));
48+
Assert.state(StringUtils.hasLength(password), "PostgreSQL password must be provided");
4849
return password;
4950
}
5051

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/postgres/PostgresJdbcDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@
2929
* @author Moritz Halbritter
3030
* @author Andy Wilkinson
3131
* @author Phillip Webb
32+
* @author Scott Frederick
3233
*/
3334
class PostgresJdbcDockerComposeConnectionDetailsFactory
3435
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
3536

37+
private static final String[] POSTGRES_CONTAINER_NAMES = { "postgres", "bitnami/postgresql" };
38+
3639
protected PostgresJdbcDockerComposeConnectionDetailsFactory() {
37-
super("postgres");
40+
super(POSTGRES_CONTAINER_NAMES);
3841
}
3942

4043
@Override

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/postgres/PostgresR2dbcDockerComposeConnectionDetailsFactory.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,12 +31,15 @@
3131
* @author Moritz Halbritter
3232
* @author Andy Wilkinson
3333
* @author Phillip Webb
34+
* @author Scott Frederick
3435
*/
3536
class PostgresR2dbcDockerComposeConnectionDetailsFactory
3637
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
3738

39+
private static final String[] POSTGRES_CONTAINER_NAMES = { "postgres", "bitnami/postgresql" };
40+
3841
PostgresR2dbcDockerComposeConnectionDetailsFactory() {
39-
super("postgres", "io.r2dbc.spi.ConnectionFactoryOptions");
42+
super(POSTGRES_CONTAINER_NAMES, "io.r2dbc.spi.ConnectionFactoryOptions");
4043
}
4144

4245
@Override

0 commit comments

Comments
 (0)