Overview of Keycloakify for React themes
.ftl) required by Keycloak, and dynamically updating asset URIs at runtime to match the hashed URLs generated by the Keycloak container.website·Indexed 29 days ago
https://willwill96.github.io/the-ui-dawg-static-site/en/introductionA front-end development blog and resource center covering topics such as Keycloakify for Keycloak themes, VS Code Devcontainers, npm package management with Verdaccio and Changesets, and cross-framework component reuse.
.ftl) required by Keycloak, and dynamically updating asset URIs at runtime to match the hashed URLs generated by the Keycloak container.# Install via npm
npm install willwill96-petfinder-graphql
# Or run via Docker
docker pull wbw4sv/petfinder-graphqlstorybook-package-context-loader is a Webpack loader designed for monorepos using Storybook. It automatically injects Storybook parameters into .stories.tsx files to provide context regarding the package containing the story.storybook-addon-package-shopping-cart is a Storybook addon that assists developers in installing components from multi-package projects.To create a containerized development environment, you need VS Code, Docker, and the 'Remote Containers' extension installed.
Ctrl/Cmd+Shift+P).Node).This workflow demonstrates how to set up a Verdaccio registry, configure the npm client to use it, publish a test version of a package, and then install that package in a separate test project to verify its functionality.
Key steps include:
.npmrc.npm-cli-login to authenticate with the local registry.--registry flag.jobs:
e2e-test:
services:
verdaccio-instance:
image: verdaccio/verdaccio
ports:
- 4873:4873
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
# Setup verdaccio as the default npm registry
- run: echo "registry=http://localhost:4873" > ~/.npmrc
- name: Publish Package
run: |
{
cd verdaccio-test
npm version 1.0.0-test-ci --git-tag-version=false
npm ci
npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873
npm publish --registry http://localhost:4873
}
- name: "Test published package"
run: |
{
cd verdaccio-test-install
npm install
npm install my-test-pkg1@1.0.0-test-ci
npm run test
}After deploying the JAR and starting Keycloak, the theme must be activated in the Admin Console:
keycloakify-starter theme from the dropdown./opt/keycloak/providers directory before the Keycloak build step is executed.FROM node:18 as keycloakify_jar_builder
RUN apt-get update && \
apt-get install -y openjdk-11-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 the JAR from the builder stage to the providers directory
COPY --from=keycloakify_jar_builder /opt/app/build_keycloak/target/keycloakify-starter-keycloak-theme-4.4.4.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"]Keycloakify projects (based on create-react-app) support standard React asset and environment management:
/public/ directory to have Keycloak host them.REACT_APP_ and access them via process.env.REACT_APP_MY_VAR.yarn storybook to preview theme changes locally.package.json correctly points to the compiled output (e.g., dist/) and includes the necessary build scripts.// package.json example
{
"name": "my-test-pkg1",
"version": "1.0.0",
"main": "dist/index.js",
"files": ["dist/"],
"scripts": {
"build": "tsc"
}
}# Publish to the registry configured in .npmrc
npm publish# Install changesets cli as a dev dependency
npm install -D @changesets/cli
# Initialize changesets
npx changeset init