In the new version of Keycloak (>=18.0.0) you'll need to build the instance with "scripts" feature enabled.
I'm doing it with environment variable:
...
ENV KC_FEATURES=account-api,account2,authorization,client-policies,impersonation,docker,scripts,upload_scripts
RUN /opt/keycloak/bin/kc.sh build
...
My full Dockerfile to build the keycloak image, if someone interested:
FROM quay.io/keycloak/keycloak:18.0.0 as builder
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=account-api,account2,authorization,client-policies,impersonation,docker,scripts,upload_scripts
ENV KC_DB=postgres
# Install custom providers
RUN curl -sL https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar -o /opt/keycloak/providers/keycloak-metrics-spi-2.5.3.jar
RUN /opt/keycloak/bin/kc.sh build
USER root
RUN chown root:root -R /opt/keycloak
FROM quay.io/keycloak/keycloak:18.0.0
COPY --from=builder --chown=keycloak:root /opt/keycloak /opt/keycloak
WORKDIR /opt/keycloak
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "--verbose", "start", "--import-realm", "--http-relative-path=/auth"]
You can also pass features as parameter: --features=
[Update] Unfortunately, keycloak removed support for upload JS scripts from admin starting version 18. So, you'll need to deploy them as .jar(zip) files. It works, but makes the development and testing of JS modules slower.
See Enabled/Disable features documentation for more details.