π₯Importing the JAR of Your Theme Into Keycloak
Now that you have your theme as a .jar file, let's see how you can import it in Keycloak so that it appears in the dropdown list for selecting theme in the Keycloak Admin console.

cd ~/github
git clone https://github.com/keycloakify/keycloakify-starter
cd keycloakify-starter
# Just to make sure these instructions remain relevant in the future
# We pin the version of the starter we are using.
git checkout 2553c38272fc76efba8f88c9add6de5ce696ba9d
yarn
yarn build-keycloak-theme
docker run \
-p 8080:8080 \
--name my-keycloak \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
-v "./dist_keycloak/keycloak-theme-for-kc-22-and-above.jar":/opt/keycloak/providers/keycloak-theme.jar \
quay.io/keycloak/keycloak:25.0.4 \
start-devHere we use "start-dev" but in production use "start --optimized"
Let's see how you would go about creating a Keycloak Docker image with your theme available.
cd ~/github
mkdir docker-keycloak-with-theme
cd docker-keycloak-with-theme
git clone https://github.com/keycloakify/keycloakify-starter
cd keycloakify-starter
# Just to make sure these instructions remain relevant in the future
# We pin the version of the starter we are using.
git checkout 2553c38272fc76efba8f88c9add6de5ce696ba9d
cd ..
cat << EOF > ./Dockerfile
FROM node:18 as keycloakify_jar_builder
RUN apt-get update && \
apt-get install -y openjdk-17-jdk && \
apt-get install -y maven;
COPY ./keycloakify-starter/package.json ./keycloakify-starter/yarn.lock /opt/app/
WORKDIR /opt/app
RUN yarn install --frozen-lockfile
COPY ./keycloakify-starter/ /opt/app/
RUN yarn build-keycloak-theme
FROM quay.io/keycloak/keycloak:latest as builder
WORKDIR /opt/keycloak
COPY --from=keycloakify_jar_builder /opt/app/dist_keycloak/keycloak-theme-for-kc-22-and-above.jar /opt/keycloak/providers/
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/
ENV KC_HOSTNAME=localhost
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start-dev"]
EOF
docker build -t docker-keycloak-with-theme .
docker run \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
-p 8080:8080 \
docker-keycloak-with-themeIn this Docker file we use ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start-dev"] but in production use ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start", "--optimized"]
Create
docker-compose.ymlfor keycloakbuild custom theme from keycloakify and get
.jarcopy and put it some where in samedocker-compose.ymldirectoryin
docker-compose.ymlfor example .jar is in themes
^^^ this volums .jar in themes in to opt/keycloak/providers/ in docker container
If you use Bitnami's Keycloak Helm chart you can leverage the initContainers parameter to load your theme.
Here we only list the rellevent values:
Read this section of the starter project readme to learn how to get GitHub Action to publish your theme's JAR as assets of your GitHub release.
What you need to know is that your keycloak-theme.jar should be placed in the provider directory of your Keycloak (e.g: /opt/keycloak/providers)
After that you should run bin/kc.sh build (e.g: bash /opt/keycloak/bin/kc.sh build)
Then you can start your Keycloak server, your theme should be available in it!
If you are utilizing a Keycloak instance managed by Cloud-IAM, importing themes and extensions is quite straightforward.
Last updated
Was this helpful?
