V1.2.0 deploy.sh angepasst

try/catch be SQL-Abfragen
This commit is contained in:
rxf
2026-03-15 13:56:16 +01:00
parent 7da9e27687
commit 23ac4ed8d7
5 changed files with 40 additions and 4 deletions

View File

@@ -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<RowDataPacket[]>(
`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

View File

@@ -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.');

View File

@@ -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 ""

19
docker-compose.local.yml Normal file
View File

@@ -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

View File

@@ -1,6 +1,6 @@
{
"name": "tabletten_next",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"scripts": {
"dev": "next dev",