gpt4 book ai didi

java - 使用 docker 启动 quarkus 时,错误 OIDC 服务器在 'quarkus.oidc.auth-server-url' URL 不可用

转载 作者:行者123 更新时间:2023-12-02 19:45:07 27 4
gpt4 key购买 nike

当我在 docker compose 中使用 Quarkus 和 Keycloak 时,我遇到了一个非常令人困惑的问题。当我设置环境变量以覆盖开发配置又名 quarkus.oidc.auth-server-url quarkus.datasource.jdbc.url 然后尝试运行 docker-compose 文件,出现错误消息。它说我的 auth-server-url 不正确,但我没有在我的 auth-server-url 中看到拼写错误或错误。
错误信息:

dbk-core    | exec java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/app.jar
dbk-core | __ ____ __ _____ ___ __ ____ ______
dbk-core | --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
dbk-core | -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
dbk-core | --\___\_\____/_/ |_/_/|_/_/|_|\____/___/
dbk-core | 11:32:08 ERROR [io.qu.application] (main) Failed to start application (with profile prod): io.quarkus.oidc.OIDCException: OIDC server is not available at the 'quarkus.oidc.auth-server-url' URL. Please make sure it is correct. Note it has to end with a realm value if you work with Keycloak, for example: 'https://localhost:8180/auth/realms/quarkus'
..........
dbk-core | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
dbk-core | at java.base/java.lang.Thread.run(Thread.java:834)
dbk-core | Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: keycloak/172.24.0.3:8180
dbk-core | Caused by: java.net.ConnectException: Connection refused
dbk-core | at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
我的 docker-compose.yml
services:
database:
build:
context: ./db-init
dockerfile: Dockerfile.db
container_name: dbk-database
ports:
- 5432:5432
volumes:
- "$HOME/databases/postgres:/var/lib/postgresql/data"
keycloak:
image: quay.io/keycloak/keycloak:latest
container_name: dbk-keycloak
environment:
DB_VENDOR: POSTGRES
DB_ADDR: database
DB_DATABASE: keycloak_database
DB_USER: keycloak
DB_SCHEMA: public
DB_PASSWORD: keycloak
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: admin
ports:
- 8180:8080
depends_on:
- database
core:
image: registry.gitlab.com/baudoku/dbk-core:dev
container_name: dbk-core
environment:
QUARKUS_OIDC_AUTH_SERVER_URL: http://keycloak:8180/auth/realms/dbk
QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://database:5432/dbk_core_database
depends_on:
- database
- keycloak
ports:
- 8080:8080
我的 Quarkus 应用程序.properties:
quarkus.oidc.auth-server-url=http://localhost:8180/auth/realms/dbk
quarkus.oidc.client-id=dbk-core
quarkus.oidc.credentials.secret=3a17e7e8-0099-49d9-8e33-d0eb954daba0

quarkus.datasource.db-kind = postgresql
quarkus.datasource.username = core
quarkus.datasource.password = core
quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/dbk_core_database
当我使用 docker 启动 keycloak 服务,并且使用 ./mvnw quarkus:dev 手动启动我的 quarkus 应用程序时,一切正常。

最佳答案

我自己解决了这个问题:) .问题是我的 quarkus.oidc.auth-server-url 因为我使用了错误的端口。解决方案是使用 keycloak 服务的内部端口,而不是暴露端口。
正确的 auth-server-url 是: http://keycloak:8080/auth/realms/dbk
正确的 jetty worker 撰写:

core:
image: registry.gitlab.com/baudoku/dbk-core:dev
container_name: dbk-core
environment:
QUARKUS_HTTP_PORT: 7000
QUARKUS_OIDC_AUTH_SERVER_URL: http://keycloak:8080/auth/realms/dbk
QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://database:5432/dbk_core_database
depends_on:
- database
- keycloak
ports:
- 8080:7000

关于java - 使用 docker 启动 quarkus 时,错误 OIDC 服务器在 'quarkus.oidc.auth-server-url' URL 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63955535/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com