Uploaded image for project: 'Red Hat build of Keycloak'
  1. Red Hat build of Keycloak
  2. RHBK-3011

Multi-stage docker builds fail --optimized validation [GHI#38893]

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      Before reporting an issue

      [x] I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

      Area

      dist/quarkus

      Describe the bug

      Running a dockerfile with --optimized that works with earlier versions fails on newer ones. I believe the commit is: https://github.com/keycloak/keycloak/commit/332bf122f1af16b4187af5ecc3129bd63e504335.

      The error is: A provider JAR was updated since the last build, please rebuild for this to be fully utilized.

      This may be similar to https://github.com/keycloak/keycloak/issues/37770, but they seemed to have resolved the issue.

      Version

      26.2

      Regression

      [ ] The issue is a regression

      Expected behavior

      This docker image can be run fine with --optimized

      Actual behavior

      It fails with ERROR: A provider JAR was updated since the last build, please rebuild for this to be fully utilized.

      How to Reproduce?

      I have the following dockerfile leveraging keycloakify:

      Unable to find source-code formatter for language: dockerfile. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      FROM node:22@sha256:0e910f435308c36ea60b4cfd7b80208044d77a074d16b768a81901ce938a62dc AS keycloakify_jar_builder
      
      RUN wget -O - https://apt.corretto.aws/corretto.key | gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg && \
      

      echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" | tee /etc/apt/sources.list.d/corretto.list && \
      apt-get update && \
      apt-get install -y java-21-amazon-corretto-jdk && \
      apt-get install -y maven;

      COPY package.json package-lock.json /opt/app/
      
      WORKDIR /opt/app
      
      RUN npm ci
      
      COPY . /opt/app/
      
      RUN npm run build-keycloak-theme
      
      FROM quay.io/keycloak/keycloak:26.2@sha256:87758ff2293c78c942c7a1f0df2bc13e0f943fcf0c0d027c12fdfac54a35d93b
      
      WORKDIR /opt/keycloak
      COPY --from=keycloakify_jar_builder /opt/app/dist_keycloak/keycloak-theme-for-kc-all-other-versions.jar /opt/keycloak/providers/
      RUN /opt/keycloak/bin/kc.sh build --db=postgres --health-enabled=true --metrics-enabled=true --tracing-enabled=true --features=opentelemetry:v1,multi-site:v1
      ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
      

      After building, running docker run 24f554b83ada start --optimized yeilds:

      ERROR: A provider JAR was updated since the last build, please rebuild for this to be fully utilized.

      I am not sure what causes this. I think it may have to do with docker COPY messing with timestamps, but don't know enough to be sure.

      For now I can run unoptimized, but this is not ideal.

      Anything else?

      Running docker run <image hash> show-config yeilds:

      Current Mode: production
      Current Configuration:
      

      kc.health-enabled = true (Persisted)
      kc.provider.file.keycloak-theme-for-kc-all-other-versions.jar.last-modified = 1744417140193 (Persisted)
      kc.log-level-org.jboss.resteasy.resteasy_jaxrs.i18n = WARN (classpath application.properties)
      kc.log-level-io.quarkus.arc.processor.BeanArchives = off (classpath application.properties)
      kc.log-level-io.quarkus.deployment.steps.ReflectiveHierarchyStep = error (classpath application.properties)
      kc.tracing-enabled = true (Persisted)
      kc.log-level-org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup = WARN (classpath application.properties)
      kc.tracing-jdbc-enabled = true (Persisted)
      kc.log-level-io.quarkus.config = off (classpath application.properties)
      kc.log-console-output = default (classpath application.properties)
      kc.metrics-enabled = true (Persisted)
      kc.log-level-io.quarkus.arc.processor.IndexClassLookupUtils = off (classpath application.properties)
      kc.db = postgres (Persisted)
      kc.log-level-io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor = warn (classpath application.properties)
      kc.optimized = true (Persisted)
      kc.version = 26.2.0 (SysPropConfigSource)
      kc.features = opentelemetry:v1,multi-site:v1 (Persisted)
      kc.run-in-container = true (ENV)

      
      

              Unassigned Unassigned
              pvlha Pavel Vlha
              Keycloak Cloud Native
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: