From 23ac4ed8d778e6efa522143174507ca217e4d469 Mon Sep 17 00:00:00 2001 From: rxf Date: Sun, 15 Mar 2026 13:56:16 +0100 Subject: [PATCH] V1.2.0 deploy.sh angepasst try/catch be SQL-Abfragen --- app/api/data/route.ts | 5 +++++ components/TablettenTable.tsx | 4 ++++ deploy.sh | 14 +++++++++++--- docker-compose.local.yml | 19 +++++++++++++++++++ package.json | 2 +- 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 docker-compose.local.yml diff --git a/app/api/data/route.ts b/app/api/data/route.ts index 7fffc4a..d5ce8f9 100644 --- a/app/api/data/route.ts +++ b/app/api/data/route.ts @@ -22,6 +22,7 @@ export async function GET(req: NextRequest) { const sord = searchParams.get('sord') === 'asc' ? 'ASC' : 'DESC'; const col = `\`${sidx}\``; + try { const [rows] = await pool.query( `SELECT tab, pday, cnt, at, akt, until, warn, rem, \`order\` FROM tabletten @@ -48,6 +49,10 @@ export async function GET(req: NextRequest) { }; return NextResponse.json(result); + } catch (err) { + console.error('[GET /api/data]', err); + return NextResponse.json({ error: String(err) }, { status: 500 }); + } } // POST /api/data diff --git a/components/TablettenTable.tsx b/components/TablettenTable.tsx index 4dc4df1..742bc68 100644 --- a/components/TablettenTable.tsx +++ b/components/TablettenTable.tsx @@ -29,6 +29,10 @@ export default function TablettenTable() { try { const res = await fetch(`/api/data?sidx=${sortField}&sord=${sortDir}`); const json = await res.json(); + if (!res.ok) { + setError(`Fehler beim Laden: ${json.error ?? res.status}`); + return; + } setRows(json.values || []); } catch { setError('Fehler beim Laden der Daten.'); diff --git a/deploy.sh b/deploy.sh index f0f1846..002619a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,21 +1,22 @@ #!/bin/bash -# Deploy Script für tabletten +# Deploy Script für laufschrift # Baut das Docker Image und lädt es zu docker.citysensor.de hoch set -e + # Konfiguration REGISTRY="docker.citysensor.de" IMAGE_NAME="tabletten" -TAG="${1:-latest}" # Erster Parameter oder "latest" +TAG="${TAG:-$(date +%Y%m%d%H%M)}" # default Datum FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${TAG}" # Build-Datum BUILD_DATE=$(date +%d.%m.%Y) echo "==========================================" -echo "Tabletten Deploy Script" +echo " Deploy Script" echo "==========================================" echo "Registry: ${REGISTRY}" echo "Image: ${IMAGE_NAME}" @@ -46,6 +47,13 @@ docker buildx build \ --push \ . +# 4. Keep :latest in sync for simple rollbacks and manual usage. +echo ">>> Tagge das image zusätzlich als :latest ..." +docker buildx imagetools create \ + -t "${REGISTRY}/${IMAGE_NAME}:latest" \ + "${FULL_IMAGE}" + + echo ">>> Build und Push erfolgreich!" echo "" diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 0000000..32c7710 --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,19 @@ +# docker-compose.local.yml +# Lokaler Betrieb – MySQL läuft bereits auf dem Host (localhost) +# +# Start: +# docker compose -f docker-compose.local.yml up --build + +services: + app: + build: + context: . + dockerfile: Dockerfile + restart: unless-stopped + ports: + - "3000:3000" + environment: + # MySQL – DB_HOST überschreibt localhost aus .env.local + DB_HOST: host.docker.internal + env_file: + - .env.local diff --git a/package.json b/package.json index 96fe4e7..ab3689c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tabletten_next", - "version": "1.1.0", + "version": "1.2.0", "private": true, "scripts": { "dev": "next dev",