Skip to content

Commit

Permalink
keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
janakrenn committed Sep 27, 2024
1 parent 9fedb91 commit 8eb80a5
Show file tree
Hide file tree
Showing 27 changed files with 368 additions and 10 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -12,11 +12,21 @@ jobs:
java-version: '21'
cache: 'maven'
cache-dependency-path: 'backend/pom.xml' # optional
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
mvn -B package
working-directory: backend
./build.sh
working-directory: ./backend
- name: Release
uses: softprops/action-gh-release@v1
with:
files: backend/traget/app/backend/target/code-with-quarkus-dev.jar
- run: echo "🍏 This job's status is ${{ job.status }}."
- run : |
./build.sh
working-directory: ./k8s
8 changes: 8 additions & 0 deletions app/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/.idea/app.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions app/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions app/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions app/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/.idea/kubernetes-settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions app/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
7 changes: 7 additions & 0 deletions app/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM eclipse-temurin:17-jre

RUN mkdir -p /opt/application
COPY target/*-runner.jar /opt/application/backend.jar
CMD [ "java", "-jar", "backend.jar" ]
# CMD [ "tail", "-f", "/dev/null"]
WORKDIR /opt/application
9 changes: 9 additions & 0 deletions app/backend/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

TAG=ghcr.io/htl-leo-itp-2325-4-5bhitm/partytiga-backend

docker build --tag=$TAG --file=Dockerfile .

docker push $TAG
4 changes: 2 additions & 2 deletions app/backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ quarkus.keycloak.devservices.realm-path=quarkus-realm.json

quarkus.keycloak.policy-enforcer.lazy-load-paths=false

# quarkus.keycloak.policy-enforcer.paths.1.path=/api/events
# quarkus.keycloak.policy-enforcer.paths.1.enforcement-mode=DISABLED
quarkus.keycloak.policy-enforcer.paths.1.path=/api/events
quarkus.keycloak.policy-enforcer.paths.1.enforcement-mode=DISABLED

quarkus.keycloak.policy-enforcer.enable=true
quarkus.keycloak.policy-enforcer.enforcement-mode=enforcing
Expand Down
9 changes: 9 additions & 0 deletions app/frontend/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

TAG=ghcr.io/htl-leo-itp-2325-4-5bhitm/partytiga-frontend

docker build --tag=$TAG --file=docker/Dockerfile .

docker push $TAG
4 changes: 4 additions & 0 deletions app/frontend/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx:stable

COPY target/* /usr/share/nginx/html/
COPY docker/default.conf /etc/nginx/conf.d/default.conf
13 changes: 13 additions & 0 deletions app/frontend/docker/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
server {
listen 80;
root /usr/share/nginx/html;
rewrite_log on;
error_log /dev/stdout debug;

location /api/ {
proxy_pass http://backend:8080;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host:$server_port;
}
}
5 changes: 4 additions & 1 deletion app/frontend/src/components/settings-component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { html,render } from "lit-html"
import { login } from "../";

export class settingsComponent extends HTMLElement {

Expand All @@ -16,6 +17,7 @@ export class settingsComponent extends HTMLElement {
console.log("setting component loaded");
}
displayContent() {
login();
return html`
<h1>Anmeldedaten</h1>
<p>Vorname</p>
Expand All @@ -26,4 +28,5 @@ export class settingsComponent extends HTMLElement {
}
}

customElements.define("event-settings", settingsComponent)
customElements.define("event-settings", settingsComponent)

6 changes: 3 additions & 3 deletions app/frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Keycloak from 'keycloak-js';
.then(json => console.log(JSON.stringify(json)));
*/

async function login() {
export async function login() {
console.log("ich bin im index.ts")
const keycloak = new Keycloak({
url: 'https://partytiga.hopto.org',
Expand All @@ -41,7 +41,7 @@ async function login() {
console.log('keycloaktoken = ' + keycloak.token)
localStorage.token=keycloak.token
}
await loadEvents()

} catch (error) {
console.error('Failed to initialize adapter:', error);
}
Expand All @@ -50,7 +50,7 @@ async function login() {
document.getElementById('profile').addEventListener("click", login)

async function start() {
await login()
await loadEvents()
}
start()

Expand Down
56 changes: 56 additions & 0 deletions app/k8s/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Quarkus Application Server
apiVersion: apps/v1
kind: Deployment
metadata:
name: appsrv

spec:
replicas: 1
selector:
matchLabels:
app: appsrv
template:
metadata:
labels:
app: appsrv
spec:
containers:
- name: appsrv
image: $BACKEND_IMAGE_NAME
# remove this when stable. Currently we do not take care of version numbers
imagePullPolicy: Always
ports:
- containerPort: 8080

# startupProbe:
# httpGet:
# path: /api/q/health
# port: 8080
# timeoutSeconds: 5
# initialDelaySeconds: 15
# readinessProbe:
# tcpSocket:
# port: 8080
# initialDelaySeconds: 5
# periodSeconds: 10
# livenessProbe:
# httpGet:
# path: /api/q/health
# port: 8080
# timeoutSeconds: 5
# initialDelaySeconds: 60
# periodSeconds: 120
---
apiVersion: v1
kind: Service
metadata:
name: appsrv

spec:
ports:
- port: 8080
targetPort: 8080
protocol: TCP
selector:
app: appsrv

1 change: 1 addition & 0 deletions app/k8s/keycloak/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keycloak-credentials.properties
25 changes: 25 additions & 0 deletions app/k8s/keycloak/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM quay.io/keycloak/keycloak:latest as builder

# Enable health and metrics support
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true

# Configure a database vendor
ENV KC_DB=postgres

WORKDIR /opt/keycloak

# for demonstration purposes only, please make sure to use proper certificates in production instead
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
RUN /opt/keycloak/bin/kc.sh build --health-enabled=true --metrics-enabled=true

FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/
# COPY ./import/ /opt/keycloak/data/import/
# change these values to point to a running postgres instance
ENV KC_DB=postgres
ENV KC_DB_URL=jdbc:postgresql://keycloak:5432/keycloak
ENV KC_DB_USERNAME=keycloak
ENV KC_DB_PASSWORD=keycloak
ENV KC_HOSTNAME=localhost
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
11 changes: 11 additions & 0 deletions app/k8s/keycloak/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e

TAG=ghcr.io/htl-leo-itp-2325-4-5bhitm/partytiga-keycloak

docker build --tag=$TAG .

docker push $TAG

#docker run --name keycloak --rm keycloak start-dev
6 changes: 6 additions & 0 deletions app/k8s/keycloak/create-secret.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash


kubectl delete secret keycloak-credentials || echo "secrets do not yet exit"
kubectl create secret generic keycloak-credentials --from-env-file=keycloak-credentials.properties

Loading

0 comments on commit 8eb80a5

Please sign in to comment.