我正在尝试设置一个带有一些自定义内容(如logback扩展名)的坞映像,因此我有一些CLI脚本,如以下脚本:
/subsystem=logging: remove()
/extension=org.jboss.as.logging: remove()
/extension=com.custom.logback: add()
/subsystem=com.custom.logback: add()我还拥有配置数据源池、主题、在keycloak-server子系统上添加一些SPI等的CLI脚本。我将这些脚本放在/opt/jboss/startup-scripts目录中。然而,当我创建容器时,事情就不能正常工作了。脚本没有按预期加载,keycloak从错误开始,而不是加载提供者(如领域使用的密码策略)。
当我使用独立的Keycloak时,所有SPI提供程序都可以很好地加载,如下所示:
2019-07-25 18:27:07.906 WARN [org.keycloak.services] (ServerService Thread Pool -- 65) KC-SERVICES0047: custom-password-policy (com.custom.login.password.PasswordSecurityPolicyFactory) is implementing the internal SPI password-policy. This SPI is internal and may change without notice
2019-07-25 18:27:07.909 WARN [org.keycloak.services] (ServerService Thread Pool -- 65) KC-SERVICES0047: custom-event (com.custom.event.KeycloakServerEventListenerProviderFactory) is implementing the internal SPI eventsListener. This SPI is internal and may change without notice
2019-07-25 18:27:08.026 WARN [org.keycloak.services] (ServerService Thread Pool -- 65) KC-SERVICES0047: custom-mailer (com.custom.mail.MessageSenderProviderFactory) is implementing the internal SPI emailSender. This SPI is internal and may change without notice
2019-07-25 18:27:08.123 WARN [org.keycloak.services] (ServerService Thread Pool -- 65) KC-SERVICES0047: custom-user-domain-verification (com.custom.login.domain.UserDomainVerificationFactory) is implementing the internal SPI authenticator. This SPI is internal and may change without notice
2019-07-25 18:27:08.123 WARN [org.keycloak.services] (ServerService Thread Pool -- 65) KC-SERVICES0047: custom-recaptcha-username-password (com.custom.login.domain.RecaptchaAuthenticatorFactory) is implementing the internal SPI authenticator. This SPI is internal and may change without notice如果我在Docker中使用相同的包,并使用jboss/keycloak:6.0.1作为映像库,则提供程序不会加载。我将作为模块使用,在$JBOSS_HOME/modules文件夹中添加并配置如下脚本:
/subsystem=keycloak-server/: write-attribute(name=providers,value=[classpath:${jboss.home.dir}/providers/*,module:com.custom.custom-keycloak-server])
/subsystem=keycloak-server/theme=defaults/: write-attribute(name=welcomeTheme,value=custom)
/subsystem=keycloak-server/theme=defaults/: write-attribute(name=modules,value=[com.custom.custom-keycloak-server])
/subsystem=keycloak-server/spi=emailSender/: add(default-provider=custom-mailer)当我在容器中执行脚本时,一切都很好。
我尝试使用卷将jar包与提供程序进行映射,并在构建自定义映像时复制jar,但这些方法都不起作用。
我使用的是jboss:keycloak:6.0.1停靠图像和Keycloak6.0.1独立文件,层和模块放在相同的目录中。
我做错什么了?将SPI提供程序与Docker一起使用的诀窍是什么,或者映像不是用于生产或这种类型的需求?
发布于 2019-09-26 08:57:50
好吧,我找到了为什么会这样
它来自opt/jboss/tools/docker-entrypoint.sh
#################
# Configuration #
#################
# If the server configuration parameter is not present, append the HA profile.
if echo "$@" | egrep -v -- '-c |-c=|--server-config |--server-config='; then
SYS_PROPS+=" -c=standalone-ha.xml"
fi它将启动密钥披风作为一个集群,因为我认为他们认为独立生产不安全
独立操作模式只在您想要运行一个、并且只运行一个Keycloak服务器实例时才有用。它不能用于集群部署,而且所有缓存都是非分布式的,并且仅限于本地缓存。不建议您在生产中使用独立模式,因为您将有一个单一的故障点。如果您的独立模式服务器出现故障,用户将无法登录。这种模式只适用于测试驱动器和播放Keycloak块引号的功能。
若要保持“独立模式”,请重写图像以将属性-c standalone.xml添加为参数:
CMD ["-b", "0.0.0.0", "-c", "standalone.xml"]发布于 2019-07-25 22:27:31
https://hub.docker.com/r/jboss/keycloak/
要添加自定义提供程序,请扩展Keycloak映像,并将提供程序添加到/opt/jboss/keycloak/独立/部署/目录中。
您是否将/opt/jboss/keycloak/standalone/deployments/的卷用于自定义提供程序?
https://stackoverflow.com/questions/57208709
复制相似问题