From 6e4f19a965f8d4b10bc8fa6f52783e7d6e3647db Mon Sep 17 00:00:00 2001 From: Sven Carstensen Date: Tue, 24 Mar 2026 11:15:18 +0100 Subject: [PATCH] Release 0.9.3 --- Dockerfile | 6 +- backend/src/main/resources/application.yml | 2 + docker_push.sh | 99 ++++++++++++++++++++++ frontend/src/globals.d.ts | 2 + frontend/src/layout/AppShell.tsx | 3 +- frontend/src/lib/version.ts | 14 --- frontend/tsconfig.node.tsbuildinfo | 2 +- frontend/vite.config.js | 37 ++++++++ frontend/vite.config.ts | 45 ++++++++++ 9 files changed, 191 insertions(+), 19 deletions(-) create mode 100755 docker_push.sh delete mode 100644 frontend/src/lib/version.ts diff --git a/Dockerfile b/Dockerfile index 3d72715..4a01c84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ WORKDIR /build/frontend ARG VITE_API_URL=/api ENV VITE_API_URL=${VITE_API_URL} +COPY backend/src/main/resources/application.yml /build/backend/src/main/resources/application.yml COPY frontend/package*.json ./ RUN npm ci @@ -19,7 +20,8 @@ RUN mvn -B -q -DskipTests dependency:go-offline COPY backend/ ./ COPY --from=frontend-build /build/frontend/dist ./src/main/resources/static -RUN mvn -B -q -DskipTests package +RUN mvn -B -q -DskipTests package \ + && cp "$(find target -maxdepth 1 -type f -name '*.jar' ! -name '*.original' | head -n 1)" /build/backend/app.jar FROM eclipse-temurin:21-jre-alpine AS runtime @@ -27,7 +29,7 @@ WORKDIR /app RUN addgroup -S spring && adduser -S spring -G spring -COPY --from=backend-build /build/backend/target/muh-backend-0.0.1-SNAPSHOT.jar /app/app.jar +COPY --from=backend-build /build/backend/app.jar /app/app.jar USER spring:spring diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 56b7d16..3b70115 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -31,6 +31,8 @@ spring: enable: ${MUH_MAIL_STARTTLS:false} muh: + app: + version: 0.9.3 cors: allowed-origins: ${MUH_ALLOWED_ORIGINS:http://localhost:5173,http://localhost:3000} security: diff --git a/docker_push.sh b/docker_push.sh new file mode 100755 index 0000000..d2080c7 --- /dev/null +++ b/docker_push.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +set -euo pipefail + +readonly SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +readonly REGISTRY_IMAGE="registry.assecutor.org/muh" +readonly APP_CONFIG_FILE="${SCRIPT_DIR}/backend/src/main/resources/application.yml" + +usage() { + cat <<'EOF' +Verwendung: + ./docker_push.sh [x.y.z] + +Beispiel: + ./docker_push.sh 0.9.13 + ./docker_push.sh + +Voraussetzungen: + - Docker Buildx ist installiert + - Login zur Registry wurde bereits ausgeführt: + docker login registry.assecutor.org + +Ohne Versionsargument wird automatisch die Version aus backend/src/main/resources/application.yml verwendet. +Optional kann VITE_API_URL als Umgebungsvariable gesetzt werden. +EOF +} + +fail() { + echo "Fehler: $*" >&2 + exit 1 +} + +require_command() { + command -v "$1" >/dev/null 2>&1 || fail "'$1' wurde nicht gefunden." +} + +resolve_app_version() { + [[ -f "${APP_CONFIG_FILE}" ]] || fail "'${APP_CONFIG_FILE}' wurde nicht gefunden." + + local version + version="$( + awk ' + $0 ~ /^muh:[[:space:]]*$/ { + in_muh = 1 + in_app = 0 + next + } + + in_muh && $0 ~ /^[^[:space:]]/ { + in_muh = 0 + in_app = 0 + } + + in_muh && $0 ~ /^[[:space:]][[:space:]]app:[[:space:]]*$/ { + in_app = 1 + next + } + + in_app && $0 ~ /^[[:space:]][[:space:]][^[:space:]]/ { + in_app = 0 + } + + in_muh && in_app && match($0, /^[[:space:]][[:space:]][[:space:]][[:space:]]version:[[:space:]]*"?([0-9]+\.[0-9]+\.[0-9]+)"?[[:space:]]*$/, a) { + print a[1] + exit + } + ' "${APP_CONFIG_FILE}" + )" + + [[ -n "${version}" ]] || fail "Version konnte nicht aus ${APP_CONFIG_FILE} ermittelt werden." + echo "${version}" +} + +VERSION="${1:-$(resolve_app_version)}" + +if [[ "${VERSION}" == "-h" || "${VERSION}" == "--help" ]]; then + usage + exit 0 +fi + +if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + fail "Versionsnummer muss das Format x.y.z haben." +fi + +require_command docker +docker buildx version >/dev/null 2>&1 || fail "Docker Buildx ist nicht verfügbar." + +cd "${SCRIPT_DIR}" + +echo "Verwende Release-Version ${VERSION}." +echo "Pushe Image ${REGISTRY_IMAGE}:${VERSION} ..." +docker buildx build \ + --platform linux/amd64 \ + --build-arg "VITE_API_URL=${VITE_API_URL:-/api}" \ + -t "${REGISTRY_IMAGE}:${VERSION}" \ + --push \ + . + +echo "Fertig: ${REGISTRY_IMAGE}:${VERSION}" diff --git a/frontend/src/globals.d.ts b/frontend/src/globals.d.ts index e37c80e..f61b5f3 100644 --- a/frontend/src/globals.d.ts +++ b/frontend/src/globals.d.ts @@ -1 +1,3 @@ +declare const __APP_VERSION__: string; + interface Worker {} diff --git a/frontend/src/layout/AppShell.tsx b/frontend/src/layout/AppShell.tsx index 008c4e4..9693ec4 100644 --- a/frontend/src/layout/AppShell.tsx +++ b/frontend/src/layout/AppShell.tsx @@ -1,6 +1,5 @@ import { NavLink, Outlet, useLocation, useNavigate } from "react-router-dom"; import { useSession } from "../lib/session"; -import { APP_VERSION } from "../lib/version"; const PAGE_TITLES: Record = { "/home": "Startseite", @@ -43,7 +42,7 @@ export default function AppShell() {