Add deployment files and documentation
- Dockerfiles, nginx config, GitLab CI and Helm chart based on the timetracker setup, adapted to DB backed sessions and group mapping - README with role model, dashboard registration and configuration - backend/.env.example Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e3e3950669
commit
98c79345a6
21 changed files with 867 additions and 0 deletions
65
.gitlab-ci.yml
Normal file
65
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
stages:
|
||||
- build
|
||||
- bundle
|
||||
- deploy
|
||||
|
||||
|
||||
BackendDocker:
|
||||
image: jonasled.dev/infra/docker-build:master@sha256:2842b062c586fc13f7db0e100302995cfdc68125bd658efbc423947fc2a6a3e3
|
||||
stage: build
|
||||
needs: []
|
||||
script:
|
||||
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/backend
|
||||
- export BUILDKIT_ADDITIONAL_ARGS="--opt filename=Dockerfile.backend"
|
||||
- build-image
|
||||
- mv image-hash.txt image-hash-backend.txt
|
||||
- mv image-scan-report.bom.json backend.bom.json
|
||||
artifacts:
|
||||
paths:
|
||||
- image-hash-backend.txt
|
||||
- backend.bom.json
|
||||
|
||||
FrontendDocker:
|
||||
image: jonasled.dev/infra/docker-build:master@sha256:2842b062c586fc13f7db0e100302995cfdc68125bd658efbc423947fc2a6a3e3
|
||||
stage: build
|
||||
needs: []
|
||||
script:
|
||||
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/frontend
|
||||
- export BUILDKIT_ADDITIONAL_ARGS="--opt filename=Dockerfile.frontend"
|
||||
- build-image
|
||||
- mv image-hash.txt image-hash-frontend.txt
|
||||
- mv image-scan-report.bom.json frontend.bom.json
|
||||
artifacts:
|
||||
paths:
|
||||
- image-hash-frontend.txt
|
||||
- frontend.bom.json
|
||||
|
||||
Helm:
|
||||
stage: bundle
|
||||
image: alpine:latest
|
||||
dependencies:
|
||||
- FrontendDocker
|
||||
- BackendDocker
|
||||
before_script:
|
||||
- apk add curl bash openssl git
|
||||
- curl -L https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
|
||||
script:
|
||||
- helm dependency update helm
|
||||
|
||||
- "export NEXT_PATCH_VERSION=\"$(cat helm/Chart.yaml | grep ^version: | cut -d ' ' -f 2 | awk -F. '{print $1 \".\" $2 \".\"}')\""
|
||||
- "sed -i \"s/^ tag: .*/ tag: $CI_COMMIT_SHA/\" helm/values.yaml"
|
||||
- "sed -i \"s/^ release: .*/ release: \\\"$CI_PIPELINE_ID\\\"/\" helm/values.yaml"
|
||||
- helm package helm --version "${NEXT_PATCH_VERSION}${CI_PIPELINE_IID}"
|
||||
artifacts:
|
||||
paths:
|
||||
- feuerwehr-schadensmeldung-*.tgz
|
||||
|
||||
Deploy Helm:
|
||||
image: curlimages/curl:latest
|
||||
stage: deploy
|
||||
script:
|
||||
- HELM_TGZ=$(ls feuerwehr-schadensmeldung-*.tgz)
|
||||
- CLEANED_BRANCH=$(echo "${CI_COMMIT_BRANCH}" | sed 's/[^a-zA-Z0-9]/-/g')
|
||||
- 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@${HELM_TGZ}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/${CLEANED_BRANCH}/charts"'
|
||||
dependencies:
|
||||
- Helm
|
||||
14
Dockerfile.backend
Normal file
14
Dockerfile.backend
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.9.0 AS xx
|
||||
FROM --platform=$BUILDPLATFORM golang:1.27.1-alpine AS build
|
||||
ARG TARGETPLATFORM
|
||||
COPY --from=xx / /
|
||||
WORKDIR /app
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
RUN go mod download
|
||||
COPY ./backend/ ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux xx-go build -ldflags "-w -s" -o /feuerwehr-schadensmeldung .
|
||||
|
||||
FROM jonasled.dev/infra/images/scratch-rootless:latest@sha256:8c33ba4e489ce0decd60f00ce63af60994b9b72cd39668284daea8eae1d809b7
|
||||
ENV GIN_MODE=release
|
||||
COPY --from=build /feuerwehr-schadensmeldung /feuerwehr-schadensmeldung
|
||||
ENTRYPOINT ["/feuerwehr-schadensmeldung"]
|
||||
10
Dockerfile.frontend
Normal file
10
Dockerfile.frontend
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
FROM --platform=$BUILDPLATFORM node:24.18-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd AS build
|
||||
WORKDIR /app
|
||||
COPY ./frontend ./
|
||||
RUN yarn install --immutable && \
|
||||
yarn build
|
||||
|
||||
FROM cgr.dev/chainguard/nginx@sha256:76cc70e5e8da88ae76ff585525c340fc09d54018c5c902551d61a24c2b3ac0d2
|
||||
WORKDIR /usr/share/nginx/html
|
||||
COPY --from=build /app/dist/ .
|
||||
COPY container/nginx.conf /etc/nginx/conf.d/nginx.default.conf
|
||||
140
README.md
Normal file
140
README.md
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
# Feuerwehr Schadensmeldung
|
||||
|
||||
Fault management for technical equipment of a German fire brigade. Members report defects on
|
||||
devices (radios, breathing apparatus, vehicles, ...), the responsible unit tracks and resolves
|
||||
them, and a public dashboard in the equipment room shows everything that is currently broken.
|
||||
|
||||
The application consists of:
|
||||
|
||||
- a Go backend with Gin, Gorm and swaggo API docs ([backend](backend))
|
||||
- a React + TypeScript frontend built with Vite ([frontend](frontend))
|
||||
|
||||
The user interface is German; code and documentation are English.
|
||||
|
||||
## Features
|
||||
|
||||
- **OIDC login** with automatic user creation. Roles are derived from OIDC groups/emails on
|
||||
every login, the identity provider is the single source of truth for role management.
|
||||
- **Faults** with title, description, device, location, priority and status
|
||||
(`open`, `in_progress`, `resolved`), filtering, full-text search and history.
|
||||
- **Fault types** (responsible unit), seeded with `IUK`, `Gerätewart` and `Atemschutz`.
|
||||
- **Categories** (kind of equipment), fully managed in the admin UI.
|
||||
- **Public dashboards** (kiosk mode) registered once by an admin with a secret: show all open
|
||||
faults, report new faults, resolve faults and browse the history without a personal login.
|
||||
- Personal **API tokens** for integrations, Swagger UI at `/api/docs/index.html`.
|
||||
- Light/dark mode, responsive layout, installable PWA.
|
||||
|
||||
## Roles
|
||||
|
||||
| Role | Granted by | Permissions |
|
||||
|-------|------------|-------------|
|
||||
| `admin` | `OIDC_ADMIN_GROUPS` or `OIDC_ADMIN_EMAILS` | everything, incl. fault types, categories, dashboards, users, branding, deleting faults |
|
||||
| `user` | any other authenticated user (optionally restricted by `OIDC_USER_GROUPS`) | report, edit, resolve and reopen faults |
|
||||
|
||||
The role is re-evaluated on every login, so removing a user from the admin group in the
|
||||
identity provider downgrades them on their next login. There is no manual role assignment in
|
||||
the application. If `OIDC_USER_GROUPS` is set, users that are neither in one of these groups
|
||||
nor admins are rejected at login.
|
||||
|
||||
## Public dashboards
|
||||
|
||||
1. An admin opens **Admin → Dashboards** and creates a dashboard (e.g. "Tablet Fahrzeughalle").
|
||||
2. A secret (`db_...`) and a registration link (`/dashboard#secret=...`) are shown **once**.
|
||||
3. On the dashboard device, open the link, or open `/dashboard` and paste the secret.
|
||||
The secret is stored in the browser's local storage and sent as `X-Dashboard-Token` header.
|
||||
4. The dashboard refreshes automatically every 30 seconds. People reporting or resolving a
|
||||
fault on the dashboard enter their name, which is stored with the fault.
|
||||
|
||||
Admins can disable a dashboard, rotate its secret or delete it; the device loses access
|
||||
immediately. Only a SHA-256 hash of the secret is stored in the database.
|
||||
|
||||
## Backend structure
|
||||
|
||||
```text
|
||||
backend/
|
||||
├── main.go entry point and swagger annotations
|
||||
├── database/ gorm connection, models, default seed data
|
||||
├── docs/ generated swagger docs (swag init --parseInternal)
|
||||
├── internal/
|
||||
│ ├── auth/ OIDC (go-oidc + PKCE), sessions, role mapping, middleware
|
||||
│ ├── faults/ fault listing, creation, resolution (shared by user and dashboard API)
|
||||
│ ├── dto/ API request/response types
|
||||
│ └── appsettings/ branding
|
||||
└── api/
|
||||
├── webserver.go, routes.go
|
||||
├── apiutil/ shared handler helpers
|
||||
├── authroutes/ /api/v1/auth/*
|
||||
├── catalogroutes/ /api/v1/catalog
|
||||
├── faultroutes/ /api/v1/faults/*
|
||||
├── meroutes/ /api/v1/me/* (API tokens)
|
||||
├── adminroutes/ /api/v1/admin/*
|
||||
├── dashboardroutes/ /api/v1/dashboard/* (public dashboards)
|
||||
├── generalroutes/ health checks
|
||||
└── staticroutes/ serves frontend/dist if present
|
||||
```
|
||||
|
||||
Sessions are stored server side (only the SHA-256 hash of the cookie value is persisted), as is
|
||||
the short-lived OIDC login state, so multiple backend replicas work without sticky sessions.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Go `1.27`
|
||||
- Node.js `22+`
|
||||
- Yarn `1.x`
|
||||
|
||||
## Local setup
|
||||
|
||||
```bash
|
||||
cp backend/.env.example backend/.env # then adjust the OIDC settings
|
||||
cd backend && go run . # http://localhost:8080
|
||||
cd frontend && yarn install && yarn dev # http://localhost:5173
|
||||
```
|
||||
|
||||
The Vite dev server proxies `/api/*` to `http://localhost:8080` (override with
|
||||
`VITE_API_PROXY_TARGET`). Register `http://localhost:5173/api/v1/auth/callback` as redirect URI
|
||||
at your identity provider (or set `OIDC_REDIRECT_URL`).
|
||||
|
||||
## Configuration
|
||||
|
||||
All configuration is done via environment variables (a `.env` file in `backend/` is loaded
|
||||
automatically).
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `DB_DRIVER` | `sqlite` | `sqlite`, `mysql`, `postgres` or `mssql` |
|
||||
| `DB_NAME` | `./database.db` | database name or sqlite file |
|
||||
| `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD` | | connection for mysql/postgres/mssql |
|
||||
| `DB_SSLMODE`, `DB_TIMEZONE` | `disable`, `Local` | postgres only |
|
||||
| `DB_ENCRYPT`, `DB_TRUST_SERVER_CERTIFICATE` | `disable`, `true` | mssql only |
|
||||
| `EXECUTE_MIGRATIONS` | `true` | run auto migrations and seed defaults on startup |
|
||||
| `OIDC_ISSUER_URL`, `OIDC_CLIENT_ID` | | required for login |
|
||||
| `OIDC_CLIENT_SECRET` | | client secret (confidential clients) |
|
||||
| `OIDC_REDIRECT_URL` | derived from request | callback URL, `/api/v1/auth/callback` |
|
||||
| `OIDC_EXTRA_SCOPES` | | additional scopes, e.g. `groups` |
|
||||
| `OIDC_GROUPS_CLAIM` | `groups` | claim containing the group list |
|
||||
| `OIDC_ADMIN_GROUPS` | | comma separated groups granting admin (exact match) |
|
||||
| `OIDC_ADMIN_EMAILS` | | comma separated emails granting admin |
|
||||
| `OIDC_USER_GROUPS` | | if set, only these groups (and admins) may log in |
|
||||
| `SESSION_LIFETIME_HOURS` | `12` | session lifetime |
|
||||
| `COOKIE_SECURE` | `false` | set `true` when served via HTTPS |
|
||||
| `TRUSTED_PROXIES` | none | comma separated proxy CIDRs for client IP detection |
|
||||
| `PORT` | `8080` | listen port |
|
||||
| `FRONTEND_DIST_DIR` | `../frontend/dist` | serve a built frontend from the backend |
|
||||
|
||||
Groups are read from both the ID token and the userinfo endpoint. The resolved groups are logged
|
||||
on every login, which helps to find the exact values for `OIDC_ADMIN_GROUPS`.
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
cd backend && go test ./... # unit and API integration tests (sqlite)
|
||||
cd backend && swag init --parseInternal # regenerate swagger docs after changing annotations
|
||||
cd frontend && yarn typecheck && yarn build
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
- `Dockerfile.backend` builds the backend binary into a scratch image.
|
||||
- `Dockerfile.frontend` builds the SPA and serves it with nginx (`container/nginx.conf`).
|
||||
- The Helm chart in [helm](helm) deploys both, routes `/api` to the backend via ingress and
|
||||
optionally deploys MariaDB.
|
||||
24
backend/.env.example
Normal file
24
backend/.env.example
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Database (sqlite, mysql, postgres or mssql)
|
||||
DB_DRIVER=sqlite
|
||||
DB_NAME=./database.db
|
||||
EXECUTE_MIGRATIONS=true
|
||||
|
||||
# OIDC login
|
||||
OIDC_ISSUER_URL=https://sso.example.org/realms/feuerwehr
|
||||
OIDC_CLIENT_ID=schadensmeldung
|
||||
OIDC_CLIENT_SECRET=change-me
|
||||
# OIDC_REDIRECT_URL=http://localhost:5173/api/v1/auth/callback
|
||||
# OIDC_EXTRA_SCOPES=groups
|
||||
# OIDC_GROUPS_CLAIM=groups
|
||||
|
||||
# Role mapping (comma separated, synchronized on every login)
|
||||
OIDC_ADMIN_GROUPS=/schadensmeldung-admins
|
||||
OIDC_ADMIN_EMAILS=admin@example.org
|
||||
# Only members of these groups (or admins) may log in. Empty allows all authenticated users.
|
||||
OIDC_USER_GROUPS=
|
||||
|
||||
SESSION_LIFETIME_HOURS=12
|
||||
COOKIE_SECURE=false
|
||||
GIN_MODE=debug
|
||||
PORT=8080
|
||||
# TRUSTED_PROXIES=10.0.0.0/8
|
||||
16
container/nginx.conf
Normal file
16
container/nginx.conf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; frame-ancestors 'none'; object-src 'none'; img-src 'self' data: blob:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; connect-src 'self'; manifest-src 'self'; worker-src 'self' blob:; media-src 'self' blob:;" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
|
||||
1
helm/.gitignore
vendored
Normal file
1
helm/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
charts/
|
||||
23
helm/.helmignore
Normal file
23
helm/.helmignore
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.orig
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
12
helm/Chart.yaml
Normal file
12
helm/Chart.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v2
|
||||
name: feuerwehr-schadensmeldung
|
||||
description: Helm chart for the Feuerwehr Schadensmeldung frontend and backend
|
||||
type: application
|
||||
version: 1.0.0
|
||||
appVersion: "1.0.0"
|
||||
|
||||
dependencies:
|
||||
- name: mariadb
|
||||
version: 26.1.7
|
||||
repository: "oci://registry-1.docker.io/bitnamicharts"
|
||||
condition: mariadb.enabled
|
||||
18
helm/templates/NOTES.txt
Normal file
18
helm/templates/NOTES.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
1. Get the application URL by running these commands:
|
||||
{{- if .Values.ingress.enabled }}
|
||||
http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.host }}{{ .Values.ingress.frontendPath }}
|
||||
{{- else if contains "NodePort" .Values.frontend.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "feuerwehr-schadensmeldung.fullname" . }}-frontend)
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.frontend.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "feuerwehr-schadensmeldung.fullname" . }}-frontend'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "feuerwehr-schadensmeldung.fullname" . }}-frontend --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.frontend.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.frontend.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "feuerwehr-schadensmeldung.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=frontend" -o jsonpath="{.items[0].metadata.name}")
|
||||
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
|
||||
{{- end }}
|
||||
62
helm/templates/_helpers.tpl
Normal file
62
helm/templates/_helpers.tpl
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "feuerwehr-schadensmeldung.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "feuerwehr-schadensmeldung.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "feuerwehr-schadensmeldung.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "feuerwehr-schadensmeldung.labels" -}}
|
||||
helm.sh/chart: {{ include "feuerwehr-schadensmeldung.chart" . }}
|
||||
{{ include "feuerwehr-schadensmeldung.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "feuerwehr-schadensmeldung.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "feuerwehr-schadensmeldung.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "feuerwehr-schadensmeldung.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "feuerwehr-schadensmeldung.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
162
helm/templates/deployment-backend.yaml
Normal file
162
helm/templates/deployment-backend.yaml
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "feuerwehr-schadensmeldung.fullname" . }}-backend
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: backend
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount.backend }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "feuerwehr-schadensmeldung.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: backend
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: backend
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "feuerwehr-schadensmeldung.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: backend
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
image: "{{ .Values.image.backend.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.backend.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.backend.service.targetPort }}
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.backend.livenessProbe.path }}
|
||||
port: http
|
||||
initialDelaySeconds: {{ .Values.backend.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.backend.livenessProbe.periodSeconds }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.backend.readinessProbe.path }}
|
||||
port: http
|
||||
initialDelaySeconds: {{ .Values.backend.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.backend.readinessProbe.periodSeconds }}
|
||||
env:
|
||||
- name: GIN_MODE
|
||||
value: {{ .Values.backend.env.ginMode | quote }}
|
||||
- name: EXECUTE_MIGRATIONS
|
||||
value: {{ ternary "true" "false" .Values.backend.env.executeMigrations | quote }}
|
||||
- name: COOKIE_SECURE
|
||||
value: {{ ternary "true" "false" .Values.backend.env.cookieSecure | quote }}
|
||||
- name: DB_DRIVER
|
||||
value: {{ .Values.database.driver | quote }}
|
||||
{{- if eq .Values.database.driver "sqlite" }}
|
||||
- name: DB_NAME
|
||||
value: {{ .Values.database.sqlitePath | quote }}
|
||||
{{- else if eq .Values.database.driver "mysql" }}
|
||||
- name: DB_NAME
|
||||
value: {{ ternary .Values.mariadb.auth.database .Values.database.external.name .Values.mariadb.enabled | quote }}
|
||||
- name: DB_USER
|
||||
value: {{ ternary .Values.mariadb.auth.username .Values.database.external.username .Values.mariadb.enabled | quote }}
|
||||
- name: DB_HOST
|
||||
value: {{ ternary (printf "%s-mariadb" .Release.Name) .Values.database.external.host .Values.mariadb.enabled | quote }}
|
||||
- name: DB_PORT
|
||||
value: {{ ternary "3306" (.Values.database.external.port | toString) .Values.mariadb.enabled | quote }}
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ if .Values.mariadb.enabled }}{{ printf "%s-mariadb" .Release.Name }}{{ else if .Values.database.external.existingSecret }}{{ .Values.database.external.existingSecret }}{{ else }}{{ include "feuerwehr-schadensmeldung.fullname" . }}-backend{{ end }}
|
||||
key: {{ if .Values.mariadb.enabled }}mariadb-password{{ else if .Values.database.external.existingSecret }}{{ .Values.database.external.existingSecretKey }}{{ else }}DB_PASSWORD{{ end }}
|
||||
{{- else if eq .Values.database.driver "postgres" }}
|
||||
- name: DB_NAME
|
||||
value: {{ .Values.database.external.name | quote }}
|
||||
- name: DB_USER
|
||||
value: {{ .Values.database.external.username | quote }}
|
||||
- name: DB_HOST
|
||||
value: {{ .Values.database.external.host | quote }}
|
||||
- name: DB_PORT
|
||||
value: {{ .Values.database.external.port | toString | quote }}
|
||||
- name: DB_SSLMODE
|
||||
value: {{ .Values.database.external.sslMode | quote }}
|
||||
- name: DB_TIMEZONE
|
||||
value: {{ .Values.database.external.timezone | quote }}
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ if .Values.database.external.existingSecret }}{{ .Values.database.external.existingSecret }}{{ else }}{{ include "feuerwehr-schadensmeldung.fullname" . }}-backend{{ end }}
|
||||
key: {{ if .Values.database.external.existingSecret }}{{ .Values.database.external.existingSecretKey }}{{ else }}DB_PASSWORD{{ end }}
|
||||
{{- else if eq .Values.database.driver "mssql" }}
|
||||
- name: DB_NAME
|
||||
value: {{ .Values.database.external.name | quote }}
|
||||
- name: DB_USER
|
||||
value: {{ .Values.database.external.username | quote }}
|
||||
- name: DB_HOST
|
||||
value: {{ .Values.database.external.host | quote }}
|
||||
- name: DB_PORT
|
||||
value: {{ .Values.database.external.port | toString | quote }}
|
||||
- name: DB_ENCRYPT
|
||||
value: {{ .Values.database.external.encrypt | quote }}
|
||||
- name: DB_TRUST_SERVER_CERTIFICATE
|
||||
value: {{ .Values.database.external.trustServerCertificate | quote }}
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ if .Values.database.external.existingSecret }}{{ .Values.database.external.existingSecret }}{{ else }}{{ include "feuerwehr-schadensmeldung.fullname" . }}-backend{{ end }}
|
||||
key: {{ if .Values.database.external.existingSecret }}{{ .Values.database.external.existingSecretKey }}{{ else }}DB_PASSWORD{{ end }}
|
||||
{{- else }}
|
||||
{{- fail (printf "Unsupported database.driver %q" .Values.database.driver) }}
|
||||
{{- end }}
|
||||
- name: OIDC_ISSUER_URL
|
||||
value: {{ .Values.backend.oidc.issuerURL | quote }}
|
||||
- name: OIDC_CLIENT_ID
|
||||
value: {{ .Values.backend.oidc.clientID | quote }}
|
||||
- name: OIDC_REDIRECT_URL
|
||||
value: {{ .Values.backend.oidc.redirectURL | quote }}
|
||||
- name: OIDC_ADMIN_EMAILS
|
||||
value: {{ .Values.backend.oidc.adminEmails | quote }}
|
||||
- name: OIDC_ADMIN_GROUPS
|
||||
value: {{ .Values.backend.oidc.adminGroups | quote }}
|
||||
- name: OIDC_USER_GROUPS
|
||||
value: {{ .Values.backend.oidc.userGroups | quote }}
|
||||
- name: OIDC_GROUPS_CLAIM
|
||||
value: {{ .Values.backend.oidc.groupsClaim | quote }}
|
||||
- name: OIDC_EXTRA_SCOPES
|
||||
value: {{ .Values.backend.oidc.extraScopes | quote }}
|
||||
- name: SESSION_LIFETIME_HOURS
|
||||
value: {{ .Values.backend.session.lifetimeHours | toString | quote }}
|
||||
{{- if or .Values.backend.oidc.clientSecret .Values.backend.oidc.existingSecret }}
|
||||
- name: OIDC_CLIENT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ if .Values.backend.oidc.existingSecret }}{{ .Values.backend.oidc.existingSecret }}{{ else }}{{ include "feuerwehr-schadensmeldung.fullname" . }}-backend{{ end }}
|
||||
key: {{ if .Values.backend.oidc.existingSecret }}{{ .Values.backend.oidc.existingSecretKey }}{{ else }}OIDC_CLIENT_SECRET{{ end }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.backend.resources | nindent 12 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
69
helm/templates/deployment-frontend.yaml
Normal file
69
helm/templates/deployment-frontend.yaml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "feuerwehr-schadensmeldung.fullname" . }}-frontend
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: frontend
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount.frontend }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "feuerwehr-schadensmeldung.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: frontend
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: frontend
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "feuerwehr-schadensmeldung.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: frontend
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
image: "{{ .Values.image.frontend.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.frontend.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.frontend.service.targetPort }}
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.frontend.livenessProbe.path }}
|
||||
port: http
|
||||
initialDelaySeconds: {{ .Values.frontend.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.frontend.livenessProbe.periodSeconds }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.frontend.readinessProbe.path }}
|
||||
port: http
|
||||
initialDelaySeconds: {{ .Values.frontend.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.frontend.readinessProbe.periodSeconds }}
|
||||
resources:
|
||||
{{- toYaml .Values.frontend.resources | nindent 12 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
45
helm/templates/ingress.yaml
Normal file
45
helm/templates/ingress.yaml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{{- if .Values.ingress.enabled }}
|
||||
{{- $fullName := include "feuerwehr-schadensmeldung.fullname" . -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.ingress.className }}
|
||||
ingressClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- host: {{ .Values.ingress.host | quote }}
|
||||
http:
|
||||
paths:
|
||||
- path: {{ .Values.ingress.apiPath }}
|
||||
pathType: {{ .Values.ingress.pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $fullName }}-backend
|
||||
port:
|
||||
number: {{ .Values.backend.service.port }}
|
||||
- path: {{ .Values.ingress.frontendPath }}
|
||||
pathType: {{ .Values.ingress.pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $fullName }}-frontend
|
||||
port:
|
||||
number: {{ .Values.frontend.service.port }}
|
||||
{{- end }}
|
||||
17
helm/templates/secret-backend.yaml
Normal file
17
helm/templates/secret-backend.yaml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{{- $useChartSecret := or .Values.backend.oidc.clientSecret (and (not .Values.mariadb.enabled) .Values.database.external.password) -}}
|
||||
{{- if $useChartSecret }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "feuerwehr-schadensmeldung.fullname" . }}-backend
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
{{- if .Values.backend.oidc.clientSecret }}
|
||||
OIDC_CLIENT_SECRET: {{ .Values.backend.oidc.clientSecret | quote }}
|
||||
{{- end }}
|
||||
{{- if and (not .Values.mariadb.enabled) .Values.database.external.password }}
|
||||
DB_PASSWORD: {{ .Values.database.external.password | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
17
helm/templates/service-backend.yaml
Normal file
17
helm/templates/service-backend.yaml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "feuerwehr-schadensmeldung.fullname" . }}-backend
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: backend
|
||||
spec:
|
||||
type: {{ .Values.backend.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.backend.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "feuerwehr-schadensmeldung.selectorLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: backend
|
||||
17
helm/templates/service-frontend.yaml
Normal file
17
helm/templates/service-frontend.yaml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "feuerwehr-schadensmeldung.fullname" . }}-frontend
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: frontend
|
||||
spec:
|
||||
type: {{ .Values.frontend.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.frontend.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "feuerwehr-schadensmeldung.selectorLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: frontend
|
||||
12
helm/templates/serviceaccount.yaml
Normal file
12
helm/templates/serviceaccount.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "feuerwehr-schadensmeldung.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
15
helm/templates/tests/test-connection.yaml
Normal file
15
helm/templates/tests/test-connection.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ include "feuerwehr-schadensmeldung.fullname" . }}-test-connection"
|
||||
labels:
|
||||
{{- include "feuerwehr-schadensmeldung.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: wget
|
||||
image: busybox
|
||||
command: ['wget']
|
||||
args: ['{{ include "feuerwehr-schadensmeldung.fullname" . }}-frontend:{{ .Values.frontend.service.port }}']
|
||||
restartPolicy: Never
|
||||
121
helm/values.yaml
Normal file
121
helm/values.yaml
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
replicaCount:
|
||||
backend: 1
|
||||
frontend: 1
|
||||
|
||||
image:
|
||||
tag: ""
|
||||
backend:
|
||||
repository: jonasled.dev/jonasled/feuerwehr-schadensmeldung/backend
|
||||
pullPolicy: IfNotPresent
|
||||
frontend:
|
||||
repository: jonasled.dev/jonasled/feuerwehr-schadensmeldung/frontend
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
imagePullSecrets: []
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
serviceAccount:
|
||||
create: true
|
||||
annotations: {}
|
||||
name: ""
|
||||
|
||||
podAnnotations: {}
|
||||
podLabels: {}
|
||||
podSecurityContext: {}
|
||||
|
||||
securityContext: {}
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
className: ""
|
||||
annotations: {}
|
||||
host: chart-example.local
|
||||
frontendPath: /
|
||||
apiPath: /api
|
||||
pathType: Prefix
|
||||
tls: []
|
||||
|
||||
nodeSelector: {}
|
||||
tolerations: []
|
||||
affinity: {}
|
||||
|
||||
backend:
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
resources: {}
|
||||
livenessProbe:
|
||||
path: /api/v1/health/liveness
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
path: /api/v1/health
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
env:
|
||||
ginMode: release
|
||||
executeMigrations: true
|
||||
cookieSecure: true
|
||||
oidc:
|
||||
issuerURL: ""
|
||||
clientID: ""
|
||||
# Optional. Derived from the request host if empty: https://<host>/api/v1/auth/callback
|
||||
redirectURL: ""
|
||||
# Comma-separated email allowlist for the admin role.
|
||||
adminEmails: ""
|
||||
# Comma-separated OIDC group values granting the admin role. Must match the claim exactly,
|
||||
# e.g. a full path such as /schadensmeldung-admins.
|
||||
adminGroups: ""
|
||||
# Optional comma-separated OIDC groups allowed to log in. Empty allows every authenticated user.
|
||||
userGroups: ""
|
||||
# Name of the claim containing the groups.
|
||||
groupsClaim: groups
|
||||
# Additional scopes, e.g. "groups" if the provider only returns groups for that scope.
|
||||
extraScopes: ""
|
||||
clientSecret: ""
|
||||
existingSecret: ""
|
||||
existingSecretKey: OIDC_CLIENT_SECRET
|
||||
session:
|
||||
lifetimeHours: 12
|
||||
extraEnv: []
|
||||
|
||||
frontend:
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
resources: {}
|
||||
livenessProbe:
|
||||
path: /
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
path: /
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
|
||||
database:
|
||||
driver: mysql
|
||||
sqlitePath: /data/database.db
|
||||
external:
|
||||
host: ""
|
||||
port: 3306
|
||||
name: schadensmeldung
|
||||
username: schadensmeldung
|
||||
sslMode: disable
|
||||
timezone: Local
|
||||
encrypt: disable
|
||||
trustServerCertificate: true
|
||||
password: ""
|
||||
existingSecret: ""
|
||||
existingSecretKey: password
|
||||
|
||||
mariadb:
|
||||
enabled: true
|
||||
auth:
|
||||
database: schadensmeldung
|
||||
username: schadensmeldung
|
||||
secondary:
|
||||
replicaCount: 0
|
||||
7
renovate.json
Normal file
7
renovate.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue