Skip to content

Commit

Permalink
Provide PostgreSQL/Keycloak mapped port information for subsequent co…
Browse files Browse the repository at this point in the history
…ntainer configuration.
  • Loading branch information
Jeremy Whiting committed Aug 20, 2024
1 parent 138c3bf commit 9c9e238
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ public Map<String, String> start(Optional<Network> network) {
boolean https = keycloakContainer.getExposedPorts().contains(8443);
String mappedPort = keycloakContainer.getMappedPort(https ? 8443 : 8080).toString();
String keycloakHost = String.format(https ? "https://%s:%s" : "http://%s:%s", keycloakContainer.getHost(), mappedPort);
System.setProperty("keycloak.container.port", mappedPort);

return Map.of(
"keycloak.host", keycloakHost,
"keycloak.container.port", mappedPort,
"keycloak.admin.url", keycloakHost.concat("/realms/master/protocol/openid-connect/token"),
"quarkus.oidc.auth-server-url", keycloakHost.concat("/auth/realms/horreum")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ public Map<String, String> start(Optional<Network> network) {
}
}
String postgresContainerName = postgresContainer.getContainerName().replaceAll("/", "");
Integer port = postgresContainer.getMappedPort(5432);
String mappedPort = postgresContainer.getMappedPort(5432).toString();
String jdbcUrl = inContainer ? postgresContainer.getJdbcUrl()
.replaceAll("localhost", networkAlias)
.replaceAll(port.toString(), "5432") : postgresContainer.getJdbcUrl();
.replaceAll(mappedPort, "5432") : postgresContainer.getJdbcUrl();
System.setProperty("postgres.container.port", mappedPort);

return Map.of(
"postgres.container.name", postgresContainerName,
"postgres.container.port", port.toString(),
"postgres.container.port", mappedPort,
"quarkus.datasource.jdbc.url", postgresContainer.getJdbcUrl(),
"quarkus.datasource.migration.jdbc.url", postgresContainer.getJdbcUrl(),
"quarkus.datasource.jdbc.url.internal", jdbcUrl
Expand Down

0 comments on commit 9c9e238

Please sign in to comment.