为啥 Keycloak 会不断重新部署相同的 .jar 文件?
Posted
技术标签:
【中文标题】为啥 Keycloak 会不断重新部署相同的 .jar 文件?【英文标题】:Why does Keycloak keep redeploying the same .jar file?为什么 Keycloak 会不断重新部署相同的 .jar 文件? 【发布时间】:2021-06-19 01:52:19 【问题描述】:我有一个自定义 SPI javascript 提供程序,打包在 .jar
文件中,如官方 Keycloak 文档中所述。
对于本地开发,我通过 docker-compose 文件使用 jboss/keycloak docker 映像,并将卷映射到 standalone/deployments
文件夹集。
该软件包已部署并且工作正常,但 Keycloak 会每 5 秒重新部署一次相同的文件:
11:43:58,304 INFO [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-8) Deploying Keycloak provider: custom-auth-provider.jar
11:43:58,320 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0013: Redeployed "custom-auth-provider.jar"
11:44:03,388 INFO [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-4) Undeploying Keycloak provider: custom-auth-provider.jar
11:44:03,395 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment custom-auth-provider.jar (runtime-name: custom-auth-provider.jar) in 9ms
11:44:03,397 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "custom-auth-provider.jar" (runtime-name: "custom-auth-provider.jar")
11:44:03,409 INFO [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-6) Deploying Keycloak provider: custom-auth-provider.jar
11:44:03,425 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "custom-auth-provider.jar" with deployment "custom-auth-provider.jar"
11:44:08,471 INFO [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-1) Undeploying Keycloak provider: custom-auth-provider.jar
11:44:08,477 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0028: Stopped deployment custom-auth-provider.jar (runtime-name: custom-auth-provider.jar) in 11ms
11:44:08,479 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "custom-auth-provider.jar" (runtime-name: "custom-auth-provider.jar")
11:44:08,493 INFO [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-5) Deploying Keycloak provider: custom-auth-provider.jar
11:44:08,517 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0013: Redeployed "custom-auth-provider.jar"
11:44:13,573 INFO [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-3) Undeploying Keycloak provider: custom-auth-provider.jar
11:44:13,581 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment custom-auth-provider.jar (runtime-name: custom-auth-provider.jar) in 11ms
这是一种理想的行为,还是我可以以某种方式阻止它?
【问题讨论】:
【参考方案1】:显然,docker-compose volumes
是问题所在。随着 Wildfly AS 自动部署 .jar
包,文件的属性发生了变化,这导致 Wildfly 将其作为更新文件使用。
将特定卷映射更改为“绑定”类型
volumes:
- type: bind # bind mount type prevents file changes
source: ./standalone/deployments/
target: /opt/jboss/keycloak/standalone/deployments
成功了
【讨论】:
【参考方案2】:我知道这会是一个迟到的答案,但是:
您应该像这样在docker-compose
中指定.jar
路径:
volumes:
- type: bind
source: ./keycloak/spi/keycloak-event-listener-spi-0.1.jar
target: /opt/jboss/keycloak/standalone/deployments/keycloak-event-listener-spi-0.1.jar
这解决了我的问题
【讨论】:
以上是关于为啥 Keycloak 会不断重新部署相同的 .jar 文件?的主要内容,如果未能解决你的问题,请参考以下文章
为啥 keycloak 会删除重定向 uri 中的 SSL?