Closed paulwer closed 1 year ago
Are you running it with the spi args?
--spi-email-template-provider=freemarker-plus-mustache \
--spi-email-template-freemarker-plus-mustache-enabled=true
Are these stack traces? Can you format them so they are readable?
@xgp i tried both, running with and without these flags only the last with stack-trace. do you nee the other ones as well?
@paulwer Thank you! Send me the full command you use to run the image, and which (if any) email theme you have selected, and I'll try to reproduce here.
@xgp Here is the dockerfile. The instance is running in google cloud run. (import of the google cloud mysql socket factory as an additional provider). it is also using a customized login theme => https://github.com/lukin/keywind
FROM quay.io/phasetwo/phasetwo-keycloak:latest as builder
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=preview,token-exchange
ENV KC_DB=mysql
# This is needed in order to use com.google.cloud.sql.mysql.SocketFactory
# More at https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/blob/main/docs/jdbc-mysql.md
ENV KC_DB_KIND=mysql
ENV KC_DB_DIALECT=org.hibernate.dialect.MySQL8Dialect
COPY mysql-socket-factory-1.8.1-jar-with-dependencies.jar /opt/keycloak/providers/
# Install custom theme
COPY /keywind/out/keywind.jar /opt/keycloak/providers/keywind-theme.jar
# Install custom providers
# RUN curl -sL https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar -o /opt/keycloak/providers/keycloak-metrics-spi-2.5.3.jar
RUN /opt/keycloak/bin/kc.sh build --transaction-xa-enabled=false
FROM quay.io/phasetwo/phasetwo-keycloak:latest
# Install socket for mysql
COPY mysql-socket-factory-1.8.1-jar-with-dependencies.jar /opt/keycloak/providers/
COPY --from=builder /opt/keycloak /opt/keycloak
WORKDIR /opt/keycloak
# for demonstration purposes only, please make sure to use proper certificates in production instead
# 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
# change these values to point to a running mysql instance
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=preview,token-exchange
ENV KEYCLOAK_ADMIN=admin
ENV KEYCLOAK_ADMIN_PASSWORD=admin
ENV KC_DB=mysql
ENV KC_DB_KIND=mysql
ENV KC_DB_DIALECT=org.hibernate.dialect.MySQL8Dialect
ENV KC_TRANSACTION_XA_ENABLED=false
# ENV KC_DB_URL="jdbc:mysql:///keycloak?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&socketFactory=com.google.cloud.sql.mysql.SocketFactory"
# ENV KC_DB_USERNAME=<MYSQL_USERNAME>
# ENV KC_DB_PASSWORD=<MYSQL_USER_PASSWORD>
ENV KC_HOSTNAME_STRICT=false
ENV KC_HTTPS_CLIENT_AUTH=request
ENV KC_HTTPS_PORT=8443
ENV KC_HTTPS_PROTOCOLS=TLSv1.3,TLSv1.2
ENV KC_HTTP_ENABLED=true
ENV KC_HTTP_PORT=8080
ENV KC_PROXY=edge
ENV PROXY_ADDRESS_FORWARDING=true
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start", "--optimized", "--spi-email-template-provider=freemarker-plus-mustache", "--spi-email-template-freemarker-plus-mustache-enabled=true"]
i tried the test-email with the following theme-providers: Attribute, base, keycloak, mustache
Thanks for the context. A similar issue was filed and I think I found what is happening. I think the missing piece is that you need to use the spi flags in the build
command as well. E.g.
RUN /opt/keycloak/bin/kc.sh build --transaction-xa-enabled=false --spi-email-template-provider=freemarker-plus-mustache --spi-email-template-freemarker-plus-mustache-enabled=true --spi-theme-cache-themes=false
I tested that successfully with something very close to your example.
thank you very much. i will try it out tomorrow. i suggest adding this as known issues within the Readme.md and a requirement for the build process.
@xgp worked, thank you very much
this error is also issued, when reseting the password:
an other error regarding the EmailTemplateProvider accurs, when using sendSmtpTestEmail endpoint
we are using the docker image