fix(symbol-arch): robuste API-Endpoints + docker-entrypoint Migration/Seed
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 14m59s

This commit is contained in:
Pepe Ziberi
2026-05-21 07:05:49 +02:00
parent e9f66b2c3d
commit 56895be16f
5 changed files with 132 additions and 42 deletions

View File

@@ -5,7 +5,11 @@ echo "=== Lageplan Startup ==="
# ─── Step 1: Run migrations (uses PrismaClient raw SQL, no CLI needed) ───
echo "[1/3] Running database migrations..."
node prisma/migrate.js || echo " Warning: migrations had issues (may be first run)"
node prisma/migrate.js
if [ $? -ne 0 ]; then
echo "❌ Database migrations failed. Aborting startup."
exit 1
fi
# ─── Step 2: Conditional seeding ───
echo "[2/3] Checking if seeding is needed..."
@@ -34,6 +38,44 @@ else
fi
fi
# ─── Step 3: Start server ───
# ─── Step 3: Seed SymbolTemplates (idempotent) ───
echo "[2b/3] Seeding symbol templates..."
node -e "
const { PrismaClient } = require('@prisma/client');
const fs = require('fs');
const path = require('path');
const prisma = new PrismaClient();
async function seedTemplates() {
const sigDir = path.join(process.cwd(), 'public', 'signaturen');
let files = [];
try { files = fs.readdirSync(sigDir).filter(f => f.endsWith('.svg')).sort(); } catch(e) { console.log('No signaturen dir'); }
let created = 0, skipped = 0;
for (let i = 0; i < files.length; i++) {
const file = files[i];
const displayName = file.replace(/\.svg$/i, '').replace(/[_-]/g, ' ').trim();
const fileKey = 'signaturen/' + file;
const existing = await prisma.symbolTemplate.findFirst({ where: { svgPath: fileKey } }).catch(() => null);
if (existing) { skipped++; continue; }
await prisma.symbolTemplate.create({
data: {
packageId: 'feuerwehr-ch',
packageName: 'Feuerwehr Schweiz',
categoryName: 'Sonstiges',
name: displayName,
svgPath: fileKey,
tags: [displayName.toLowerCase()],
sortOrder: i,
}
}).catch(() => {});
created++;
}
console.log('Templates: ' + created + ' created, ' + skipped + ' skipped');
await prisma.\$disconnect();
}
seedTemplates().catch(() => { console.log('Template seed skipped'); prisma.\$disconnect(); });
" || echo " Warning: template seed failed"
# ─── Step 4: Start server ───
echo "[3/3] Starting server..."
exec node server-custom.js