From a50fe144b95ed460f4d2b0a3097aaabe5efe6d40 Mon Sep 17 00:00:00 2001 From: Felix Dittrich <31076102+f11h@users.noreply.github.com> Date: Fri, 27 Jan 2023 10:53:42 +0100 Subject: [PATCH] Feat: Upgrade Keycloak 20+ (#100) * Modify Dockerfile for Keycloak Quarkus * Fix Copy * Add extra image for Admin-IAM * Fix CI Job Fix Dockerfile * Fix Dockerfile * Fix Dockerfile * Fix Dockerfile * Update Image Tag for Admin Iam * Add Theme-Property Files for Quicktest Theme * Update Dockerfile --- .github/workflows/ci-master.yml | 21 +- Dockerfile | 42 +- Dockerfile-QT | 25 - .../configuration/standalone-ha-qt.xml | 733 ----------------- .../configuration/standalone-ha.xml | 738 ------------------ src/themes/cwa/account/theme.properties | 2 + src/themes/cwa/login/theme.properties | 3 + .../quick-test/account/theme.properties | 2 + src/themes/quick-test/login/theme.properties | 3 + 9 files changed, 44 insertions(+), 1525 deletions(-) delete mode 100644 Dockerfile-QT delete mode 100644 src/standalone/configuration/standalone-ha-qt.xml delete mode 100644 src/standalone/configuration/standalone-ha.xml create mode 100644 src/themes/cwa/login/theme.properties create mode 100644 src/themes/quick-test/login/theme.properties diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 50591a4..667fa6a 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -5,7 +5,7 @@ on: branches: - master jobs: - build: + build-public: runs-on: ubuntu-latest steps: - uses: sigstore/cosign-installer@main @@ -20,6 +20,7 @@ jobs: --tag docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:latest \ --tag docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:${VERSION} \ --tag ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION} \ + --build-arg IAM_FLAVOUR=public \ . env: MTR_REPOSITORY: ${{ secrets.MTR_REPOSITORY }} @@ -41,7 +42,7 @@ jobs: MTR_TOKEN: ${{ secrets.MTR_TOKEN }} MTR_PRIVATE_KEY: ${{ secrets.MTR_PRIVATE_KEY }} COSIGN_PASSWORD: ${{ secrets.MTR_PRIVATE_KEY_PASSWORD }} - build-qt: + build-admin: runs-on: ubuntu-latest steps: - uses: sigstore/cosign-installer@main @@ -53,25 +54,25 @@ jobs: - name: docker build run: | docker build \ - --tag docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:latest-qt \ - --tag docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:${VERSION}-qt \ - --tag ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION}-qt \ - -f ./Dockerfile-QT \ + --tag docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:latest-ADMIN \ + --tag docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:${VERSION}-ADMIN \ + --tag ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION}-ADMIN \ + --build-arg IAM_FLAVOUR=admin \ . env: MTR_REPOSITORY: ${{ secrets.MTR_REPOSITORY }} - name: docker push github run: | echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY_OWNER} --password-stdin - docker push docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:latest-qt - docker push docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:${VERSION}-qt + docker push docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:latest-ADMIN + docker push docker.pkg.github.com/${GITHUB_REPOSITORY}/cwa-verification-iam:${VERSION}-ADMIN env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: docker push mtr run: | echo ${MTR_TOKEN} | docker login ${MTR_REPOSITORY} -u ${MTR_USER} --password-stdin - docker push ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION}-qt - cosign sign --key env://MTR_PRIVATE_KEY ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION}-qt + docker push ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION}-ADMIN + cosign sign --key env://MTR_PRIVATE_KEY ${MTR_REPOSITORY}/cwa-verification-iam:${VERSION}-ADMIN env: MTR_REPOSITORY: ${{ secrets.MTR_REPOSITORY }} MTR_USER: ${{ secrets.MTR_USER }} diff --git a/Dockerfile b/Dockerfile index 40b2d2c..77b3159 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,29 @@ -FROM quay.io/keycloak/keycloak:15.1.0 +ARG IAM_FLAVOUR=public +FROM quay.io/keycloak/keycloak:20.0.3 as base-image -ARG WORK_DIR=/build -WORKDIR ${WORK_DIR} +# Enables Features for Admin Flavour of IAM Image +FROM base-image as builder-admin +ENV KC_FEATURES_ENABLED=admin2,admin-api -COPY . ${WORK_DIR}/ +# Disable Features for Public Flavour of IAM Image +FROM base-image as builder-public +ENV KC_FEATURES_DISABLED=admin,admin2,admin-api -RUN mkdir /opt/jboss/keycloak/themes/cwa && \ - mkdir /opt/jboss/keycloak/themes/quick-test && \ - cp -r /opt/jboss/keycloak/themes/base/* /opt/jboss/keycloak/themes/cwa/ && \ - cp -r ${WORK_DIR}/src/themes/cwa/login /opt/jboss/keycloak/themes/cwa/ && \ - cp -r ${WORK_DIR}/src/themes/cwa/account /opt/jboss/keycloak/themes/cwa/ && \ - cp -r /opt/jboss/keycloak/themes/base/* /opt/jboss/keycloak/themes/quick-test/ && \ - cp -r ${WORK_DIR}/src/themes/quick-test/login /opt/jboss/keycloak/themes/quick-test/ && \ - cp -r ${WORK_DIR}/src/themes/quick-test/account /opt/jboss/keycloak/themes/quick-test/ && \ - cp ${WORK_DIR}/src/standalone/configuration/standalone-ha.xml /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml +FROM builder-${IAM_FLAVOUR} as builder +WORKDIR /opt/keycloak +ENV KC_HEALTH_ENABLED=true +ENV KC_METRICS_ENABLED=false +ENV KC_CACHE=ispn +ENV KC_CACHE_STACK=kubernetes +ENV KC_DB=postgres +COPY src/themes/cwa /opt/keycloak/themes/cwa +COPY src/themes/quick-test /opt/keycloak/themes/quick-test +RUN /opt/keycloak/bin/kc.sh build -EXPOSE 8080 -EXPOSE 8443 -EXPOSE 7080 -EXPOSE 7443 +FROM base-image +COPY --from=builder /opt/keycloak/ /opt/keycloak/ -ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ] +EXPOSE 8443 -CMD ["-b", "0.0.0.0"] +ENTRYPOINT ["/opt/keycloak/bin/kc.sh"] +CMD ["start", "--optimized"] diff --git a/Dockerfile-QT b/Dockerfile-QT deleted file mode 100644 index e0ec3ca..0000000 --- a/Dockerfile-QT +++ /dev/null @@ -1,25 +0,0 @@ -FROM quay.io/keycloak/keycloak:14.0.0 - -ARG WORK_DIR=/build -WORKDIR ${WORK_DIR} - -COPY . ${WORK_DIR}/ - -RUN mkdir /opt/jboss/keycloak/themes/cwa && \ - mkdir /opt/jboss/keycloak/themes/quick-test && \ - cp -r /opt/jboss/keycloak/themes/base/* /opt/jboss/keycloak/themes/cwa/ && \ - cp -r ${WORK_DIR}/src/themes/cwa/login /opt/jboss/keycloak/themes/cwa/ && \ - cp -r ${WORK_DIR}/src/themes/cwa/account /opt/jboss/keycloak/themes/cwa/ && \ - cp -r /opt/jboss/keycloak/themes/base/* /opt/jboss/keycloak/themes/quick-test/ && \ - cp -r ${WORK_DIR}/src/themes/quick-test/login /opt/jboss/keycloak/themes/quick-test/ && \ - cp -r ${WORK_DIR}/src/themes/quick-test/account /opt/jboss/keycloak/themes/quick-test/ && \ - cp ${WORK_DIR}/src/standalone/configuration/standalone-ha-qt.xml /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml - -EXPOSE 8080 -EXPOSE 8443 -EXPOSE 7080 -EXPOSE 7443 - -ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ] - -CMD ["-b", "0.0.0.0"] diff --git a/src/standalone/configuration/standalone-ha-qt.xml b/src/standalone/configuration/standalone-ha-qt.xml deleted file mode 100644 index 5ef9660..0000000 --- a/src/standalone/configuration/standalone-ha-qt.xml +++ /dev/null @@ -1,733 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - h2 - - sa - sa - - - - jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE - h2 - - sa - sa - - - - - org.h2.jdbcx.JdbcDataSource - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - auth - - - classpath:${jboss.home.dir}/providers/* - - - master - 900 - - 2592000 - true - true - ${env.KEYCLOAK_WELCOME_THEME:keycloak} - ${env.KEYCLOAK_DEFAULT_THEME:keycloak} - ${jboss.home.dir}/themes - - - - - - - - - - - - - jpa - - - basic - - - - - - - - - - - - - - - - - - - default - - - - - - - - ${keycloak.jta.lookup.provider:jboss} - - - - - - - - - - - ${keycloak.x509cert.lookup.provider:default} - - - - default - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/standalone/configuration/standalone-ha.xml b/src/standalone/configuration/standalone-ha.xml deleted file mode 100644 index dbdc20f..0000000 --- a/src/standalone/configuration/standalone-ha.xml +++ /dev/null @@ -1,738 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - h2 - - sa - sa - - - - jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE - h2 - - sa - sa - - - - - org.h2.jdbcx.JdbcDataSource - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - auth - - - classpath:${jboss.home.dir}/providers/* - - - master - 900 - - 2592000 - true - true - ${env.KEYCLOAK_WELCOME_THEME:keycloak} - ${env.KEYCLOAK_DEFAULT_THEME:keycloak} - ${jboss.home.dir}/themes - - - - - - - - - - - - - jpa - - - basic - - - - - - - - - - - - - - - - - - - default - - - - - - - - ${keycloak.jta.lookup.provider:jboss} - - - - - - - - - - - ${keycloak.x509cert.lookup.provider:default} - - - - default - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/themes/cwa/account/theme.properties b/src/themes/cwa/account/theme.properties index f038496..66a162e 100644 --- a/src/themes/cwa/account/theme.properties +++ b/src/themes/cwa/account/theme.properties @@ -1 +1,3 @@ +parent=base +import=common/keycloak locales=de diff --git a/src/themes/cwa/login/theme.properties b/src/themes/cwa/login/theme.properties new file mode 100644 index 0000000..66a162e --- /dev/null +++ b/src/themes/cwa/login/theme.properties @@ -0,0 +1,3 @@ +parent=base +import=common/keycloak +locales=de diff --git a/src/themes/quick-test/account/theme.properties b/src/themes/quick-test/account/theme.properties index f038496..66a162e 100644 --- a/src/themes/quick-test/account/theme.properties +++ b/src/themes/quick-test/account/theme.properties @@ -1 +1,3 @@ +parent=base +import=common/keycloak locales=de diff --git a/src/themes/quick-test/login/theme.properties b/src/themes/quick-test/login/theme.properties new file mode 100644 index 0000000..66a162e --- /dev/null +++ b/src/themes/quick-test/login/theme.properties @@ -0,0 +1,3 @@ +parent=base +import=common/keycloak +locales=de