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 sord = searchParams.get('sord') === 'asc' ? 'ASC' : 'DESC';
const col = `\`${sidx}\``; const col = `\`${sidx}\``;
try {
const [rows] = await pool.query<RowDataPacket[]>( const [rows] = await pool.query<RowDataPacket[]>(
`SELECT tab, pday, cnt, at, akt, until, warn, rem, \`order\` `SELECT tab, pday, cnt, at, akt, until, warn, rem, \`order\`
FROM tabletten FROM tabletten
@@ -48,6 +49,10 @@ export async function GET(req: NextRequest) {
}; };
return NextResponse.json(result); return NextResponse.json(result);
} catch (err) {
console.error('[GET /api/data]', err);
return NextResponse.json({ error: String(err) }, { status: 500 });
}
} }
// POST /api/data // POST /api/data

View File

@@ -29,6 +29,10 @@ export default function TablettenTable() {
try { try {
const res = await fetch(`/api/data?sidx=${sortField}&sord=${sortDir}`); const res = await fetch(`/api/data?sidx=${sortField}&sord=${sortDir}`);
const json = await res.json(); const json = await res.json();
if (!res.ok) {
setError(`Fehler beim Laden: ${json.error ?? res.status}`);
return;
}
setRows(json.values || []); setRows(json.values || []);
} catch { } catch {
setError('Fehler beim Laden der Daten.'); setError('Fehler beim Laden der Daten.');

View File

@@ -1,21 +1,22 @@
#!/bin/bash #!/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 # Baut das Docker Image und lädt es zu docker.citysensor.de hoch
set -e set -e
# Konfiguration # Konfiguration
REGISTRY="docker.citysensor.de" REGISTRY="docker.citysensor.de"
IMAGE_NAME="tabletten" 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}" FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${TAG}"
# Build-Datum # Build-Datum
BUILD_DATE=$(date +%d.%m.%Y) BUILD_DATE=$(date +%d.%m.%Y)
echo "==========================================" echo "=========================================="
echo "Tabletten Deploy Script" echo " Deploy Script"
echo "==========================================" echo "=========================================="
echo "Registry: ${REGISTRY}" echo "Registry: ${REGISTRY}"
echo "Image: ${IMAGE_NAME}" echo "Image: ${IMAGE_NAME}"
@@ -46,6 +47,13 @@ docker buildx build \
--push \ --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 ">>> Build und Push erfolgreich!"
echo "" 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", "name": "tabletten_next",
"version": "1.1.0", "version": "1.2.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",