Hello everyone,
I want to use CrateDB for my Keycloak server that is running as a Docker Container. Using the Postgres Driver that Keycloak offers, I get some problems with SQL statements that are not supported by Crate (ROLLBACK amongst others). So I figured I can try using the Crate JDBC standalone driver instead.
In my dockerfile, I am downloading the jar and then adding the path to the Classpath. Then I am using the Crate URL and login which work for example in Spring Boot. My Dockerfile is attached below. However when running the container, I get the Exception
java.lang.ClassNotFoundException: io.crate.client.jdbc.CrateDriver
I am not sure where there problem is here. I can see that the jar is correctly downloaded into the drivers folder. Is the drivers name ( io.crate.client.jdbc.CrateDriver
) correct or do I need to provide a whole path? Or is there any problem that prohibits using Keycloak and Crate together at all?
Dockerfile:
>
> FROM quay.io/keycloak/keycloak:latest as builder
>
> # Configure a database vendor
> ENV KC_DB=postgres
>
> WORKDIR /opt/keycloak
>
> RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
> RUN /opt/keycloak/bin/kc.sh build
>
> FROM quay.io/keycloak/keycloak:latest
> COPY --from=builder /opt/keycloak/ /opt/keycloak/
>
> ADD --chown=keycloak:keycloak https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/crate-jdbc-standalone-2.7.0.jar /drivers/
>
> ENV CLASSPATH=/drivers/crate-jdbc-standalone-2.7.0.jar
>
> ENV KC_DB=postgres
> ENV KC_DB_URL=jdbc:postgresql://<ip_address>:5432/doc
> ENV KC_DB_USERNAME=user
> ENV KC_DB_PASSWORD=password
> ENV KC_DB_DRIVER=io.crate.client.jdbc.CrateDriver
> ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]