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 d3d4b18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 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 @@ -126,6 +126,8 @@ public void startHorreumContainers(
keycloakConfig.put("horreum.keycloak.url", keycloakURL);
keycloakConfig.put("quarkus.oidc.auth-server-url", keycloakURL + "/realms/horreum");
keycloakConfig.put("quarkus.oidc.credentials.secret", envvars.get("quarkus.oidc.credentials.secret"));
keycloakConfig.put(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME, horreumBuildTimeConfig.keycloak.adminUsername);
keycloakConfig.put(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD, horreumBuildTimeConfig.keycloak.adminPassword);
if (envvars.containsKey("quarkus.oidc.tls.trust-store-file")) {
keycloakConfig.put("quarkus.oidc.tls.trust-store-file", envvars.get("quarkus.oidc.tls.trust-store-file"));
keycloakConfig.put("quarkus.oidc.tls.verification", "required"); // "certificate-validation" validates the certificate chain, but not the hostname. could also be "none" and disable TLS verification altogether
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,11 @@ 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));

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

keycloak = KeycloakBuilder.builder()
.serverUrl(keycloakEnv.get("keycloak.host"))
.realm(KEYCLOAK_REALM)
.username(keycloakAdminUser)
.password(keycloakAdminPassword)
.username(initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME))
.password(initArgs.get(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD))
.clientId("admin-cli")
.resteasyClient(((ResteasyClientBuilder) ClientBuilder.newBuilder()).disableTrustManager().build())
.build();
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 d3d4b18

Please sign in to comment.