Skip to content

Instantly share code, notes, and snippets.

@deangrant
Last active November 30, 2022 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deangrant/7c4b209ff19b65a6bb0d35e972bf4b5d to your computer and use it in GitHub Desktop.
Save deangrant/7c4b209ff19b65a6bb0d35e972bf4b5d to your computer and use it in GitHub Desktop.
Dockerfile to deploy themes as an archive to Keycloak
FROM alpine:latest AS themes
ADD /themes /themes
WORKDIR /themes
RUN apk add openjdk11 && \
jar cf custom.jar META-INF/ theme/
# Example dockerfile from https://www.keycloak.org/server/containers.
FROM quay.io/keycloak/keycloak:latest as builder
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_DB=postgres
COPY --from=themes /themes/custom.jar /opt/keycloak/providers/custom.jar
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/
ENV KC_DB_URL=<DBURL>
ENV KC_DB_USERNAME=<DBUSERNAME>
ENV KC_DB_PASSWORD=<DBPASSWORD>
ENV KC_HOSTNAME=localhost
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment