I'm currently working with RH-SSO 7.6 image in local development. With standard Keycloak images I can configure DB connection to my custom Postgres database using proper environment variables, but I'm not able to reach the same with RH-SSO image. In that case, Keycloak connects to H2 database by default.
So far, I tried to look into Openshift RH-SSO-76 templates to check exact ENVs to set DB connection, and I ended up with following docker-compose. Also, I'm building my custom image from Dockerfile (adding custom providers, themes etc.)
docker-compose
version: '3.4'
services:
keycloak:
build:
context: .
dockerfile: Dockerfile
environment:
- SSO_ADMIN_USERNAME=admin
- SSO_ADMIN_PASSWORD=admin
- DB_USERNAME=keycloak
- DB_PASSWORD=password
- DB_JNDI=java=jboss/datasources/KeycloakDS
- DB_DRIVER_NAME=postgresql
- DB_DRIVER=org.postgresql
- DB_JDBC_URL=jdbc:postgresql://postgres/keycloak
networks:
- postgres-network
ports:
- "8080:8080"
- "9990:9990"
- "8787:8787"
container_name: keycloak_rhsso
postgres:
image: postgres:9.6
environment:
- POSTGRES_DB=keycloak
- POSTGRES_USER=keycloak
- POSTGRES_PASSWORD=password
- POSTGRES_ROOT_PASSWORD=password
networks:
- postgres-network
ports:
- "5432:5432"
container_name: keycloak_db_rhsso
networks:
postgres-network:
driver: bridge
Then I tried to edit JBoss configuration based on RH documentation RHSSO Openshift Doc, but when I tried to remove datasource (KeycloakDS) from subsystem, I got an error that KeycloakDS not found.
So my questions are, if it's possible to set Keycloak datasource via ENVs and if not, how to automatically change JBoss configuration while building custom image from RHSSO 7.6 image.
Thanks for any advices.