我正在尝试使用一些自定义内容(例如 logback 扩展)设置 docker 映像,因此我有一些 CLI 脚本,例如:
/subsystem=logging: remove()
/extension=org.jboss.as.logging: remove()
/extension=com.custom.logback: add()
/subsystem=com.custom.logback: add()
我还有 CLI 脚本来配置数据源池、主题、在keycloak-server子系统上添加一些 SPI 等。我将这些脚本放在/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.1docker image 和 Keycloak 6.0.1 独立,层和模块放在相同的目录中。
我做错了什么?将 SPI 提供程序与 Docker 一起使用有什么技巧,或者该映像不是用于生产或此类需求的?