[keycloak-user] Setting web context path and adding providers in Dockerfile

Sushil Singh sushil.singh at guavus.com
Tue Nov 19 03:54:55 EST 2019


If you want to run locally ,  try minikube to run kubernetes locally  https://kubernetes.io/docs/setup/learning-environment/minikube/

Use Kubernetes Configmaps if you wish to change the content of xml files and use it in your deployment
Use volumeMounts if you wish to use the custom paths

Here is an example

ConfigMap File

config.yaml


=======================================================

apiVersion: v1

data:

  standalone.xml: |



// paste content of complete standalone xml file with your customization


kind: ConfigMap

metadata:

  labels:

    app: keycloak

  name: keycloak-scripts-cm

==================================================




===============================================================
Deployment File (deploy.yaml)

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: keycloak
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      containers:
        -
          env:
            -
              name: KEYCLOAK_USER
              value: admin
            -
              name: KEYCLOAK_PASSWORD
              value: admin
            -
              name: PROXY_ADDRESS_FORWARDING
              value: "true"
          image: jboss/keycloak
          name: keycloak
          ports:
            -
              containerPort: 8080
              name: http
            -
              containerPort: 8443
              name: https
          readinessProbe:
            httpGet:
              path: /auth/realms/master
              port: 8080
          volumeMounts:
            -
              mountPath: /opt/jboss/keycloak/standalone/configuration/standalone.xml
              name: keycloak-data
              subPath: standalone.xml
      volumes:
        -
          configMap:
            name: keycloak-scripts-cm
          name: keycloak-data
========================================================================

So , Basically your  mountPath is mapped to the configmap .And you will be able to see your customizations once the server gets started.

Installing Kubernetes with Minikube - Kubernetes<https://kubernetes.io/docs/setup/learning-environment/minikube/>
Documentation. Learn how to use Kubernetes with conceptual, tutorial, and reference documentation. You can even help contribute to the docs!
kubernetes.io

Hope it will help !!


From: Sebastian Rus <russebastian.ui at gmail.com>
Sent: 19 November 2019 13:35
To: Sushil Singh <sushil.singh at guavus.com>
Subject: Re: [keycloak-user] Setting web context path and adding providers in Dockerfile

Yes, the target goal is to have it on kubernetes, but for testing I'm playing around with my local docker. Did you manage to change the default context path or add custom probviders?

________________________________
From: keycloak-user-bounces at lists.jboss.org <keycloak-user-bounces at lists.jboss.org> on behalf of Sushil Singh <sushil.singh at guavus.com>
Sent: 19 November 2019 13:30
To: Sebastian Rus <russebastian.ui at gmail.com>; keycloak-user at lists.jboss.org <keycloak-user at lists.jboss.org>
Subject: Re: [keycloak-user] Setting web context path and adding providers in Dockerfile

Are you using kubernetes?? I have done a similar thing for kubernetes
________________________________
From: keycloak-user-bounces at lists.jboss.org <keycloak-user-bounces at lists.jboss.org> on behalf of Sebastian Rus <russebastian.ui at gmail.com>
Sent: 19 November 2019 13:01
To: keycloak-user at lists.jboss.org <keycloak-user at lists.jboss.org>
Subject: [keycloak-user] Setting web context path and adding providers in Dockerfile

I'm struggling with extending keycloak's docker image, so that I could
change the default web-context "/auth" path
in /opt/jboss/keycloak/standalone/configuration/standalone.xml
and /opt/jboss/keycloak/domain/configuration/domain.xml files. I tried to
use jboss-cli.sh to accomplish it, but the following Dockerfile:

FROM jboss/keycloak:7.0.0
COPY startup-config.cli /opt/jboss/tools/cli/startup-config.cli
RUN /opt/jboss/keycloak/bin/jboss-cli.sh
--file="/opt/jboss/tools/cli/startup-config.cli"
ENV KEYCLOAK_USER=admin
ENV KEYCLOAK_PASSWORD=admin

startup-config.cli:
/subsystem=keycloak-server:write-attribute(name=web-context,value=keycloak/auth)

build command ends with "No connection to the controller."

I also would like to add some custom providers to the <providers> section
of standalone.xml file:

       <providers>           ...
<provider>module:x.y.z.some-custom-provider</provider>
</providers>

Is it possible to edit that xml files using custom Dockerfile and
extending default keycloak image?

I will be extremally grateful for help.


Best regards,

Sebastian
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user


More information about the keycloak-user mailing list