Skip to content

Commit

Permalink
Fix devservices with DB backup
Browse files Browse the repository at this point in the history
  • Loading branch information
barreiro committed Feb 7, 2024
1 parent 17aebe1 commit 70abffd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions horreum-backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ quarkus.keycloak.admin-client.grant-type=CLIENT_CREDENTIALS
%dev.quarkus.keycloak.admin-client.client-id=admin-cli
%dev.quarkus.keycloak.admin-client.realm=master
%dev.quarkus.keycloak.admin-client.grant-type=PASSWORD
%dev.quarkus.keycloak.admin-client.username=admin
%dev.quarkus.keycloak.admin-client.password=secret
%dev.quarkus.keycloak.admin-client.username=${horreum.dev-services.keycloak.admin-username}
%dev.quarkus.keycloak.admin-client.password=${horreum.dev-services.keycloak.admin-password}

# Secret used to sign database rows
horreum.db.secret=secret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ public static Map<String, String> startContainers(Map<String, String> initArgs)
envVariables.put("quarkus.oidc.auth-server-url", keycloakEnv.get("keycloak.host").concat("/realms/").concat(HORREUM_REALM));
envVariables.putAll(oidcTruststoreProperties(initArgs));

if (!initArgs.containsKey(HORREUM_DEV_POSTGRES_BACKUP)) {

String keycloakAdminUser = initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME);
String keycloakAdminPassword = initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD);

envVariables.put(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME, keycloakAdminUser);
envVariables.put(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD, keycloakAdminPassword);

keycloak = KeycloakBuilder.builder()
.serverUrl(keycloakEnv.get("keycloak.host"))
.realm(KEYCLOAK_REALM)
Expand All @@ -175,7 +180,6 @@ public static Map<String, String> startContainers(Map<String, String> initArgs)
.resteasyClient(((ResteasyClientBuilder) ClientBuilder.newBuilder()).disableTrustManager().build())
.build();

if (!initArgs.containsKey(HORREUM_DEV_POSTGRES_BACKUP)) {
// Not using a backup db, so need to create the dummy roles

// Obtain client secrets for Horreum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public void init(Map<String, String> initArgs) {
throw new RuntimeException("Arguments did not contain Keycloak image");
}

final String JDBC_URL = initArgs.get("quarkus.datasource.jdbc.url.internal");
final String DB_PORT = initArgs.get("postgres.container.port");

final String KEYCLOAK_IMAGE = initArgs.get(HORREUM_DEV_KEYCLOAK_IMAGE);

networkAlias = initArgs.get(HORREUM_DEV_KEYCLOAK_NETWORK_ALIAS);
Expand Down Expand Up @@ -73,7 +70,7 @@ public void init(Map<String, String> initArgs) {
.env("KC_HTTP_ENABLED", "true")
.env("KC_HOSTNAME_STRICT", "false")
.env("DB_DATABASE", "keycloak")
.env("KC_DB_URL", JDBC_URL)
.env("KC_DB_URL", initArgs.get("quarkus.datasource.jdbc.url.internal"))
.run("/opt/keycloak/bin/kc.sh build")
.entryPoint("/opt/keycloak/bin/kc.sh ${KEYCLOAK_COMMAND:-start-dev} --import-realm $EXTRA_OPTIONS")
.build()).withFileFromFile("/tmp/keycloak-horreum.json", tempKeycloakRealmFile);
Expand All @@ -100,7 +97,7 @@ public void init(Map<String, String> initArgs) {
.withEnv("KC_DB_URL_HOST", "")
.withEnv("KC_HOSTNAME_STRICT", "false")
.withEnv("KC_HOSTNAME", "localhost")
.withEnv("KC_DB_URL", "jdbc:postgresql://172.17.0.1:" + DB_PORT + "/keycloak")
.withEnv("KC_DB_URL", "jdbc:postgresql://" + initArgs.get(HORREUM_DEV_POSTGRES_NETWORK_ALIAS) + ":5432/keycloak")
.withCommand("-Dquarkus.http.http2=false", "start-dev");
}

Expand Down

0 comments on commit 70abffd

Please sign in to comment.