Scaffold the app, chart, CI and release (26.11.1)
ci / olares chart · sanity (pull_request) Successful in 5s
ci / app · types + tests + build (pull_request) Successful in 3m54s
release / which version (pull_request) Successful in 1s
release / olares chart · sanity (pull_request) Successful in 3s
release / app (pull_request) Successful in 1m25s
release / tag and release (pull_request) Skipped

Next.js 15 with next-intl (de, en, fr, es; locale per person, no URL
prefix), Tailwind v4 tokens for the warm palette with dark mode, a
shadcn/ui button, Serwist service worker and PWA manifest with icons.
One Postgres pool with withHousehold() setting app.household_id per
transaction; the first migration creates households with FORCE ROW
LEVEL SECURITY, and a two-household test checks the isolation as the
table owner. scripts/migrate.mjs applies db/migrations once each with a
checksum and retries until the database is reachable.

Olares chart with one deployment (init: chown, migrate from the same
image), ClusterIP service, entrance internal until the own sign-in
exists, image path fixed in the template and tag from appVersion.
scripts/check-chart.sh carries the rules from Rocket; CI runs it, type
check, tests against Postgres and the build; release builds
lunch-app, tags and attaches the chart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HUc2nv7rJVU2gp3Bgtha3q
This commit is contained in:
Kai BöhmandClaude Opus 5.5 committed 2026-11-06 19:08:21 +00:00
1 parent 14c0973ac6
commit fa83e560b2
52 files changed
+6474 -3

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
// Erzeugt die Symbole der PWA aus docs/icon/lunch.svg (Chromium über
// Playwright, nur lokal nötig): public/icon.svg, apple-touch-icon.png,
// icon-192.png, icon-512.png, icon-512-maskable.png und olares/icon.png (512 × 512, geht als lunch/icon.png nach aimighty/bilder).
// Ändert sich das Symbol, alle neu erzeugen und mit committen.
import { copyFile, readFile } from "node:fs/promises";
import { createRequire } from "node:module";
// Playwright ist keine Abhängigkeit des Projekts; global installiert reicht.
const { chromium } = createRequire(import.meta.url)("playwright");
const svg = await readFile("docs/icon/lunch.svg", "utf8");
const browser = await chromium.launch();
const page = await browser.newPage();
async function render(file, size, { maskable = false } = {}) {
// Maskierbar: Motiv auf 80 % in sicherer Zone, Rand in Terrakotta.
const inner = maskable ? Math.round(size * 0.8) : size;
await page.setViewportSize({ width: size, height: size });
await page.setContent(`<html><body style="margin:0;background:${maskable ? "#b8573a" : "transparent"};display:grid;place-items:center;width:${size}px;height:${size}px">
<div style="width:${inner}px;height:${inner}px">${svg.replace("<svg ", `<svg width="${inner}" height="${inner}" `)}</div></body></html>`);
await page.screenshot({ path: file, omitBackground: !maskable });
}
await copyFile("docs/icon/lunch.svg", "public/icon.svg");
await render("public/apple-touch-icon.png", 180, { maskable: true });
await render("public/icon-192.png", 192);
await render("public/icon-512.png", 512);
await render("public/icon-512-maskable.png", 512, { maskable: true });
await render("olares/icon.png", 512);
await browser.close();
console.log("icons written");
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
# Prüft das Olares-Chart vor jedem Commit und in der CI. Jede Regel steht
# für einen Fehler, der bei Rocket oder Insilo auf der Box Geld gekostet hat
# (Vorbild: aimighty/rocket scripts/check-chart.sh).
set -euo pipefail
cd "$(dirname "$0")/.."
FEHLER=0
melde() { echo " FEHLER: $*"; FEHLER=1; }
echo "→ Versionen im Gleichschritt"
CHART_VERSION=$(grep -E '^version:' olares/Chart.yaml | awk '{print $2}')
CHART_APPVERSION=$(grep -E '^appVersion:' olares/Chart.yaml | awk '{print $2}' | tr -d '"')
MANIFEST_VERSION=$(grep -E '^ version:' olares/OlaresManifest.yaml | awk '{print $2}')
MANIFEST_VERSIONNAME=$(grep -E '^ versionName:' olares/OlaresManifest.yaml | awk '{print $2}' | tr -d "'")
[ "$CHART_VERSION" = "$CHART_APPVERSION" ] || melde "Chart.yaml: version ($CHART_VERSION) != appVersion ($CHART_APPVERSION)"
[ "$CHART_VERSION" = "$MANIFEST_VERSION" ] || melde "OlaresManifest metadata.version ($MANIFEST_VERSION) != Chart-version ($CHART_VERSION)"
[ "$CHART_APPVERSION" = "$MANIFEST_VERSIONNAME" ] || melde "OlaresManifest spec.versionName ($MANIFEST_VERSIONNAME) != appVersion ($CHART_APPVERSION)"
# YY.M.<n>, Monat ohne führende Null — mit Null ist es kein gültiges SemVer.
echo "$CHART_VERSION" | grep -Eq '^[0-9]{2}\.([1-9]|1[0-2])\.[1-9][0-9]*$' \
|| melde "Version '$CHART_VERSION' folgt nicht YY.M.<n> (z. B. 26.11.1)"
echo "→ Root-Manifest ist eine Kopie des Chart-Manifests"
cmp -s OlaresManifest.yaml olares/OlaresManifest.yaml \
|| melde "OlaresManifest.yaml (Wurzel) weicht von olares/OlaresManifest.yaml ab — cp olares/OlaresManifest.yaml ."
echo "→ Namen identisch (Chart, metadata.name, appid)"
for wert in \
"$(grep -E '^name:' olares/Chart.yaml | awk '{print $2}')" \
"$(grep -E '^ name: ' olares/OlaresManifest.yaml | head -1 | awk '{print $2}')" \
"$(grep -E '^ appid:' olares/OlaresManifest.yaml | awk '{print $2}')"
do
[ "$wert" = "lunch" ] || melde "Name weicht ab: '$wert' (erwartet: lunch)"
done
ohne_kommentare() { grep -rhvE '^[[:space:]]*#' olares/templates/; }
suche_verboten() {
if ohne_kommentare | grep -qE "$1"; then melde "$2 gefunden"; ohne_kommentare | grep -nE "$1" | head -3; fi
}
echo "→ Kein .Files.Get, keine Helm-Hooks, kein NodePort/LoadBalancer/hostNetwork"
suche_verboten '\.Files\.Get' ".Files.Get"
suche_verboten 'helm\.sh/hook' "Helm-Hook"
suche_verboten 'NodePort|LoadBalancer|hostNetwork' "verbotener Netzwerktyp"
echo "→ Manifest v3"
API_VERSION=$(grep -E '^apiVersion:' olares/OlaresManifest.yaml | awk '{print $2}' | tr -d "'\"")
DEP_VERSION=$(awk '/^[[:space:]]*-[[:space:]]*name:[[:space:]]*olares[[:space:]]*$/{f=1} f&&/^[[:space:]]*version:/{gsub(/.*version:[[:space:]]*/,""); gsub(/['"'"'"]/,""); print; exit}' olares/OlaresManifest.yaml)
[ "$API_VERSION" = "v3" ] || melde "OlaresManifest ohne apiVersion v3"
[ "$DEP_VERSION" = ">=1.12.6-0" ] || melde "options.dependencies[olares].version muss '>=1.12.6-0' sein, ist '$DEP_VERSION'"
grep -qE '^[[:space:]]*runAsInternal:[[:space:]]*true' olares/OlaresManifest.yaml && melde "runAsInternal: true im Manifest"
grep -rq 'OLARES_USER' olares/ && melde "OLARES_USER kommt in olares/ vor (v3 verbietet das Präfix)"
for tpl in olares/templates/deployment*.yaml; do
grep -q 'index .Values.workloads' "$tpl" || melde "$tpl liest replicas nicht aus .Values.workloads"
done
echo "→ Abbild: Pfad fest im Template, Tag aus Chart.AppVersion"
if grep -n 'image:' olares/templates/deployment*.yaml | grep -q 'repository'; then
melde "ein Template liest den Abbild-Pfad aus values.yaml"
fi
grep -q 'image: "git.aimighty.olares.de/aimighty/lunch-app:' olares/templates/deployment.yaml \
|| melde "deployment.yaml zieht nicht git.aimighty.olares.de/aimighty/lunch-app"
grep -q 'default .Chart.AppVersion' olares/templates/deployment.yaml \
|| melde "deployment.yaml liest den Tag nicht aus Chart.AppVersion"
if grep -qE '^\s+tag: "[^"]+"' olares/values.yaml; then
echo " Hinweis: values.yaml pinnt einen Tag — nur für ein Release ohne neue Abbilder richtig."
fi
echo "→ Bilder aus aimighty/bilder, nichts von GitHub"
grep -qi 'github' olares/OlaresManifest.yaml && melde "OlaresManifest.yaml nennt GitHub"
BILDER="https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/"
for feld in icon featuredImage; do
grep -E "^[[:space:]]*$feld:" olares/OlaresManifest.yaml | grep -vqF "$BILDER" && melde "$feld liegt nicht unter $BILDER"
done
echo "→ Entrance erst public, wenn die eigene Anmeldung steht (E-0001)"
if grep -qE '^[[:space:]]*authLevel:[[:space:]]*public' olares/OlaresManifest.yaml && [ ! -f lib/auth/session.ts ]; then
melde "Entrance ist public, aber lib/auth/session.ts fehlt — erst die eigene Anmeldung, dann öffnen"
fi
echo "→ Markt-Notiz zur Version"
MV="$CHART_VERSION"
if [ ! -f "olares/markt/$MV.md" ]; then
melde "olares/markt/$MV.md fehlt — '# Titel', 'v$MV: …' (Englisch), '## Deutsch', 'v$MV: …'"
else
head -1 "olares/markt/$MV.md" | grep -q '^# ' || melde "olares/markt/$MV.md: erste Zeile '# <Titel>'"
sed -n 2p "olares/markt/$MV.md" | grep -q "^v$MV: " || melde "olares/markt/$MV.md: Text beginnt mit 'v$MV: '"
! grep -q '`' "olares/markt/$MV.md" || melde "olares/markt/$MV.md: kein Backtick"
awk '/^## Deutsch[[:space:]]*$/{f=1;next} f&&NF{print;exit}' "olares/markt/$MV.md" | grep -q "^v$MV: " \
|| melde "olares/markt/$MV.md: deutscher Teil fehlt — Zeile '## Deutsch', darunter 'v$MV: …'"
fi
echo "→ helm lint und helm template"
helm lint olares -f olares/values-olares-stub.yaml > /dev/null || melde "helm lint fehlgeschlagen"
helm template lunch olares -f olares/values-olares-stub.yaml > /dev/null || melde "helm template fehlgeschlagen"
if [ "$FEHLER" -eq 0 ]; then echo "Alles in Ordnung."; else echo "Prüfung fehlgeschlagen."; exit 1; fi
+83
View File
@@ -0,0 +1,83 @@
// Spielt db/migrations/*.sql in Namensreihenfolge ein — als Vorlauf-Container
// auf der Box (olares/templates/deployment.yaml) und lokal mit `npm run migrate`.
//
// Jede Datei läuft einmal, in einer eigenen Transaktion, und wird mit
// Prüfsumme in schema_migrations vermerkt. Eine schon angewandte Datei, deren
// Inhalt sich geändert hat, ist ein Fehler: Migrationen werden nie
// nachträglich bearbeitet, sondern durch eine neue ergänzt.
//
// Die Wiederholschleife beim Verbinden deckt das Fenster ab, in dem Olares
// das ns-owner-Label noch nicht gesetzt hat und die NetworkPolicy den Weg zur
// Datenbank sperrt (bei Insilo und Rocket gelernt; kein Helm-Hook).
import { createHash } from "node:crypto";
import { readdir, readFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import pg from "pg";
const DIR = process.env.MIGRATIONS_DIR ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "db", "migrations");
function config() {
if (process.env.DATABASE_URL) return { connectionString: process.env.DATABASE_URL };
return {
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT ?? 5432),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
};
}
async function connect(attempts = Number(process.env.MIGRATE_ATTEMPTS ?? 60), pause = 5000) {
let last;
for (let i = 1; i <= attempts; i++) {
const client = new pg.Client({ ...config(), connectionTimeoutMillis: 4000 });
try {
await client.connect();
return client;
} catch (error) {
last = error;
console.log(` attempt ${i}/${attempts}: ${error.message}`);
await client.end().catch(() => {});
if (i < attempts) await new Promise((r) => setTimeout(r, pause));
}
}
throw last;
}
async function main() {
console.log("waiting for postgres …");
const client = await connect();
try {
await client.query(`create table if not exists schema_migrations (
name text primary key, checksum text not null, applied_at timestamptz not null default now())`);
const done = new Map((await client.query("select name, checksum from schema_migrations")).rows.map((r) => [r.name, r.checksum]));
const files = (await readdir(DIR)).filter((f) => f.endsWith(".sql")).sort();
for (const file of files) {
const sql = await readFile(path.join(DIR, file), "utf8");
const sum = createHash("sha256").update(sql).digest("hex");
if (done.has(file)) {
if (done.get(file) !== sum) throw new Error(`${file} was changed after it was applied — add a new migration instead`);
continue;
}
console.log(`applying ${file}`);
await client.query("begin");
try {
await client.query(sql);
await client.query("insert into schema_migrations (name, checksum) values ($1, $2)", [file, sum]);
await client.query("commit");
} catch (error) {
await client.query("rollback");
throw new Error(`${file}: ${error.message}`);
}
}
console.log(`migrations up to date (${files.length} files)`);
} finally {
await client.end();
}
}
main().catch((error) => {
console.error(error.message);
process.exit(1);
});