From 45e54a85673db140f0c2714972a624ee2c5dd275 Mon Sep 17 00:00:00 2001 From: Stephan Schnabel Date: Tue, 5 Dec 2023 09:50:20 +0100 Subject: [PATCH] Add example theme in integration tests (#139) --- README.md | 2 +- pom.xml | 16 ++++++++++++++ src/main/docker/Dockerfile | 8 +++++++ .../kokuwa/login/resources/css/styles.css | 1 + .../themes/kokuwa/login/theme.properties | 2 ++ .../k3s/test/keycloak/files/kokuwa-realm.json | 1 + src/test/k3s/test/keycloak/statefulset.yaml | 21 +++++++++++++++++++ 7 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/docker/themes/kokuwa/login/resources/css/styles.css create mode 100644 src/main/docker/themes/kokuwa/login/theme.properties diff --git a/README.md b/README.md index 9a901d1..f34c64f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Keycloak container image for Kokuwa. - logs as json - ispn cache - preconfigured tag for realm import from directory `/realms` (see [job.yaml](/src/test/k3s/keycloak/job.yaml)) -- [integration test](/src/test/k3s) with [k3s](https://k3s.io/) +- [integration test](/src/test/k3s) with [k3s](https://k3s.io/) and deployment of [example theme](/src/main/docker/themes/kokuwa) ## Why diff --git a/pom.xml b/pom.xml index 6e8019b..fbcd981 100644 --- a/pom.xml +++ b/pom.xml @@ -306,6 +306,21 @@ + + docker-themes + package + + exec + + + + build + ${project.build.directory}/docker + --tag=${image.name}:${image.tag}-themes + --target=themes + + + docker @@ -340,6 +355,7 @@ ${image.name}:${image.tag}-${image.tag.test} ${image.name}:${image.tag}-${image.tag.test}-import + ${image.name}:${image.tag}-themes diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 3739368..4cca026 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -162,3 +162,11 @@ ENV KC_DB=postgres KC_CACHE=local KC_LOG_CONSOLE_OUTPUT=json COPY --from=keycloak-import /app /app ENTRYPOINT ["java", "-XX:+ExitOnOutOfMemoryError", "-Dkc.home.dir=/app", "-jar", "/app/lib/quarkus-run.jar"] CMD ["import", "--dir=/realms"] + +### +### Themes +### + +FROM docker.io/library/debian:stable-slim AS themes + +COPY themes /themes diff --git a/src/main/docker/themes/kokuwa/login/resources/css/styles.css b/src/main/docker/themes/kokuwa/login/resources/css/styles.css new file mode 100644 index 0000000..57f3469 --- /dev/null +++ b/src/main/docker/themes/kokuwa/login/resources/css/styles.css @@ -0,0 +1 @@ +.login-pf body { background: DimGrey none; } diff --git a/src/main/docker/themes/kokuwa/login/theme.properties b/src/main/docker/themes/kokuwa/login/theme.properties new file mode 100644 index 0000000..48159d7 --- /dev/null +++ b/src/main/docker/themes/kokuwa/login/theme.properties @@ -0,0 +1,2 @@ +parent=keycloak +styles=css/login.css css/styles.css diff --git a/src/test/k3s/test/keycloak/files/kokuwa-realm.json b/src/test/k3s/test/keycloak/files/kokuwa-realm.json index 1460f15..0615764 100644 --- a/src/test/k3s/test/keycloak/files/kokuwa-realm.json +++ b/src/test/k3s/test/keycloak/files/kokuwa-realm.json @@ -2,6 +2,7 @@ "id": "kokuwa-id", "enabled": true, "realm": "kokuwa", + "loginTheme": "kokuwa", "attributes": { "frontendUrl": "http://auth.kokuwa.127.0.0.1.nip.io:8080" }, diff --git a/src/test/k3s/test/keycloak/statefulset.yaml b/src/test/k3s/test/keycloak/statefulset.yaml index 5c035f9..fafc73a 100644 --- a/src/test/k3s/test/keycloak/statefulset.yaml +++ b/src/test/k3s/test/keycloak/statefulset.yaml @@ -18,6 +18,23 @@ spec: prometheus.io/port: "8080" prometheus.io/path: /realms/master/metrics spec: + initContainers: + - name: keycloak-themes + image: ${image.name}:${image.tag}-themes + imagePullPolicy: Never + command: [cp, -r, /themes/kokuwa, /app/themes] + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + runAsNonRoot: true + readOnlyRootFilesystem: true + privileged: false + allowPrivilegeEscalation: false + capabilities: + drop: [ALL] + volumeMounts: + - name: themes + mountPath: /app/themes containers: - name: keycloak image: ${image.name}:${image.tag}-${image.tag.test} @@ -60,6 +77,8 @@ spec: volumeMounts: - name: data mountPath: /app/data + - name: themes + mountPath: /app/themes - name: tmp mountPath: /tmp enableServiceLinks: false @@ -68,5 +87,7 @@ spec: volumes: - name: data emptyDir: {} + - name: themes + emptyDir: {} - name: tmp emptyDir: {}