Commit Graph

8 Commits

Author SHA1 Message Date
3fb195f679 Drei Fallen in den Windows-Skripten, die sicher zuschlagen wuerden
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 12m38s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m43s
CI / Ausrollen (push) Successful in 7s
Vorbereitung des ersten Laufs auf einer echten Windows-Maschine. Nur die
Stellen, bei denen der Fehler feststeht und das Skript daran haengenbleibt --
alles Uebrige wird am laufenden Objekt entschieden, nicht erraten.

Dienstkonto ueber CIM statt ueber nssm: `nssm set <dienst> ObjectName <konto>
''` uebergibt ein leeres Argument an ein natives Programm, und Windows
PowerShell 5.1 laesst es je nach Fassung weg oder reicht zwei
Anfuehrungszeichen weiter. Win32_Service.Change nimmt Konto und Passwort als
benannte Werte -- da gibt es nichts zu zitieren.

Get-Website ohne -Name: der Filter wird in mehreren Fassungen von
WebAdministration ignoriert und liefert alle Sites. Auf jedem frisch
eingerichteten IIS steht die "Default Web Site" -- die Pruefung waere also
immer wahr gewesen und haette die IIS-Einrichtung jedes Mal mit einer Meldung
abgebrochen, die nicht stimmt.

freischalten.ps1 leitete sein Zielverzeichnis aus dem eigenen Ort ab. Das
stimmt nur in der Installation; aus dem ausgepackten Paket aufgerufen zeigte
es dorthin und meldete "MIGRATE_DATABASE_URL fehlt" -- ein Hinweis auf die
falsche Datei. Jetzt fest, mit einer Pruefung, die sagt was gemeint ist.

Geprueft: alle acht Skripte werden vom Parser der echten Windows PowerShell
5.1 angenommen (nicht nur von PowerShell 7, wie bisher), und keine Datei
enthaelt ein Byte ueber 127.
2026-10-13 18:06:46 +02:00
05073cc816 Der Dienst schaltet die Telemetrie ab, wie das Abbild es tut
Das Containerabbild setzt NEXT_TELEMETRY_DISABLED, der Windows-Dienst setzte
es nicht. Ein Unterschied zwischen zwei Betriebsarten, den niemand beabsichtigt
hat -- und auf einem Server, der Personaldaten haelt, soll die Anwendung von
sich aus mit niemandem sprechen ausser der eigenen Datenbank und dem
Anmeldedienst.

Gefunden beim Abgleich der beiden Betriebsarten Zeile fuer Zeile: Umgebung,
Proxy-Header, Rollen und Erweiterungen der Datenbank, Variablenvorlagen. Alles
uebrige deckt sich; die Abweichung bei HOSTNAME (0.0.0.0 im Container,
127.0.0.1 als Dienst) ist beabsichtigt und richtig.
2026-10-13 18:01:54 +02:00
7d5e0b03c8 Das Windows-Paket laesst sich jetzt auch auf Windows bauen
Erster Schritt der Umstellung auf Windows Server: die vorhandenen Skripte
wurden bisher nie auf Windows ausgefuehrt. Vier Befunde aus dem ersten
Versuch, alle reproduzierbar.

1. Die Standalone-Ausgabe lag eine Ebene tiefer. Next sucht sich die Wurzel
   selbst und nimmt die aeusserste Sperrdatei, die es findet; liegt eine
   Ebene ueber dem Projekt eine fremde package-lock.json, entsteht
   .next/standalone/<ordner>/server.js statt .next/standalone/server.js.
   Dockerfile und windows-paket.mjs suchen beide die zweite Form -- dasselbe
   Repository baute damit auf einem Rechner ein brauchbares Paket und auf dem
   naechsten keines. Die Wurzel ist jetzt in next.config.ts festgenagelt.

2. ESLint pruefte dist/. Der Ordner steht in .gitignore, aber das liest
   ESLint nicht, und darin liegt eine vollstaendige Kopie der Anwendung samt
   node_modules: nach einem einzigen Paketbau meldete npm run check ueber
   tausend Fehler aus fremdem Code.

3. Der naechtliche Lauf entschied auf dem Statuscode statt auf der Antwort.
   Genau diese Regel hat im Docker-Betrieb wochenlang einen Totalausfall
   verdeckt: ohne Sitzung kam die Anmeldeseite -- mit 200. Die Weiterleitung
   faengt -MaximumRedirection 0 ab, eine direkt ausgelieferte Seite nicht.
   Erfolg heisst jetzt wie unter Linux: die Antwort enthaelt "applied".

4. Der Rauchtest fehlte im Paket. Er ist die einzige Pruefung, die die
   Funktionen aufruft statt ihren Text zu lesen -- ohne ihn gibt es auf dem
   Zielserver keine Moeglichkeit festzustellen, ob die Anwendung dort nicht
   nur startet, sondern auch arbeitet.

Dazu eine Kleinigkeit in Wait-Gesund: die Pause stand nur im catch, eine
durchkommende Antwort ungleich 200 drehte neunzig Sekunden lang eine
Schleife ohne Pause.
2026-10-13 17:55:22 +02:00
muena
efc4390ab3 Betrieb auf Windows Server ohne Docker
All checks were successful
CI / Migrationen auf leerer Datenbank (push) Successful in 10m32s
CI / Ausrollen (push) Successful in 7s
CI / Lint, Typen, Tests, Build (push) Successful in 11m43s
Der Kunde betreibt die Anwendung auf einem Windows Server mit
vorhandenem Node.js und PostgreSQL, ohne Docker. Ausgeliefert wird ein
fertiges Paket (npm run paket:windows, rund 8 MB Zip); auf dem Server
braucht es weder npm noch einen Build.

- scripts/windows-paket.mjs: Standalone-Build plus Migrationen und
  Betriebsskripte. Loest die Turbopack-Symlinks auf und laesst sharp
  weg (next/image wird nicht benutzt); bricht ab, sobald eine native
  Datei oder ein Symlink im Paket landet.
- scripts/db-setup.mjs: ersetzt deploy/db-init ausserhalb des
  Containers -- Datenbank mit ICU de-AT, Anwendungsrolle ohne BYPASSRLS,
  Erweiterungen, auth-Attrappe. Wiederholbar, liest nur DATABASE_URL und
  MIGRATE_DATABASE_URL.
- deploy/windows/: Installation (Dienst ueber NSSM als LocalService,
  nur auf 127.0.0.1), Update mit Sicherung vorab, Nachtlauf und
  Sicherung als geplante Aufgaben, IIS als HTTPS-Proxy, Freischaltung
  der ersten Person, Anleitung.
- engines: Node bis 26.

Geprueft: Paket auf dem Mac gebaut, entpackt an einem fremden Pfad
unter Linux mit Node 26 gegen PostgreSQL 18 eingerichtet, migriert und
gestartet (/login, Logo, CSS, Nachtlauf 401/200). Die PowerShell-Skripte
sind nur geparst, auf Windows selbst noch nicht gelaufen.
2026-10-12 10:06:11 +02:00
a164b537b8 Automatischer Deploy ueberspringt sich ohne Secrets
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m13s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m11s
CI / Ausrollen (push) Successful in 5s
Ausgerollt wird derzeit von Hand auf dem Server. Ohne DEPLOY_*-Secrets
endet der CI-Job "Ausrollen" deshalb gruen mit Hinweis auf
deploy/ausrollen.sh, statt jeden Push rot zu faerben. Teilweise
eingetragene Secrets und der manuelle Deploy-Workflow scheitern weiterhin
laut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 13:37:13 +02:00
aed4c3e210 Deploy per SSH nach gruener CI, mit Migrationen
Some checks failed
CI / Lint, Typen, Tests, Build (push) Successful in 11m26s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m10s
CI / Ausrollen (push) Failing after 5s
Der bisherige Deploy-Workflow lief ueber den Docker-Socket des Runners und
erreichte seit dem Umzug auf den eigenen db-Container die Datenbank nicht
mehr; er war deshalb abgeschaltet, und Migrationen blieben beim Ausrollen
von Hand aus (die Berichtsseite fiel ueber die fehlende Spalte
zustaendige_hr_id).

- deploy/ausrollen.sh (auf dem Server): Commit vorspulen, laufenden
  Compose-Stapel aus den Container-Labels erkennen, bauen, Migrationen
  (dry-run, dann echt), up -d, auf healthy warten. Sperre gegen parallele
  Laeufe, laeuft bei Verbindungsabbruch zu Ende.
- deploy/ueber-ssh.sh (im Job): SSH mit Schluessel und known_hosts aus
  Secrets, reicht ausrollen.sh hinein.
- ci.yml: Job "Ausrollen" nach check und migrationen, nur Push auf master.
- deploy.yml: derselbe Weg von Hand.
- DEPLOYMENT.md: Einrichtung der Secrets, Updates von Hand mit migrate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 13:11:39 +02:00
77d9a95f7f Run the database in a container of our own
Some checks failed
CI / Lint, Typen, Tests, Build (push) Failing after 5m25s
CI / Integrationstests (echtes Postgres) (push) Failing after 5m9s
Supabase was only ever the host: the application has talked to PostgreSQL
directly through pg/Kysely for a while. So the move is mostly about
supplying what the platform used to supply.

Proved before building anything. All 65 migrations replay onto an empty
database, and the result matches production exactly — 183 columns, 25
policies, 68 indexes, 84 constraints, identical sets, no diff. The only
function missing from the rebuild turned out to matter, see below.

What the platform supplied, deploy/db-init now does:

  - alpenwerk_app, explicitly NOBYPASSRLS. The whole access model is 21
    RLS policies; a role that bypasses them would leave everything
    working while showing too much, and nobody would notice.
  - pgcrypto and pg_trgm. uuid-ossp was available on Supabase but is
    used nowhere — no column default, no function calls uuid_generate_*.
  - anon, authenticated and service_role as NOLOGIN placeholders. No
    policy names them; they only carry grants the platform handed out,
    and a data dump referencing them would fail to restore without them.
  - A stub `auth` schema. The end state needs none of it — checked: no
    foreign key, no policy, no column default refers to it. The June
    2026 migrations do, and rewriting those would be falsifying history;
    they describe what was true then.

The gap the comparison found: rls_auto_enable() and the ensure_rls event
trigger existed only in the running database, created by hand, in no
migration. That is the net which forces RLS on every newly created
table — the reason a forgotten policy yields an empty table instead of
an open one. A rebuild from migrations would silently not have had it:
everything works, and the next new table is unprotected. Now a migration
(20260819100000), verified by creating a table on the rebuild and
confirming RLS came on by itself.

Data moves separately, via scripts/umzug-von-supabase.sh: schema from
the migrations, then pg_dump --data-only --disable-triggers for the rows.
Without --disable-triggers every foreign key trips over load order. RLS
does not interfere — none of the 19 tables uses FORCE ROW LEVEL
SECURITY, so the owner writes through. The dump is deliberately left on
disk afterwards.

psql and node come from two `tools`-profile services rather than being
installed on the host, so the server needs nothing but Docker. The db
service publishes no port at all — reachable only inside the compose
network.

SUPABASE_DB_URL is renamed MIGRATE_DATABASE_URL, since after this it
describes something else entirely; the old name still works so existing
.env files keep running. Both were exercised, as was the error when
neither is set.

The deploy workflow is set to manual-only. Its preconditions were never
met — no secrets, and whether the job container can reach the host's
Docker daemon is untested — and failing on every push teaches people to
ignore red runs. It also needs updating for the new database service
before it could work at all.

Not verified: none of this has run in an actual container. There is no
Docker daemon on this machine. What is verified is the part that
decides whether it can work — the schema, on a real empty database.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 16:34:08 +02:00
780f8fe2b7 Write down what an internal deployment actually needs
The target is a VM inside the company network, reachable only from there.
Two consequences decide whether this works at all, and both are easy to
discover too late — after the firewall rules are already written.

The server needs outbound access even though nothing comes in. Auth.js
exchanges the authorisation code for a token server-side and fetches the
issuer's configuration, so login.microsoftonline.com must be reachable from
the VM; the database likewise. That the person signs in through their own
browser is not enough, which is the assumption worth naming before someone
builds a closed network around it.

HTTPS is not optional either: Entra accepts http only for localhost. The
practical route without public reachability is a public DNS name pointing at
a private address and a certificate obtained through the DNS challenge —
allowed, common, and it yields a normally trusted certificate while the
server stays unreachable from outside. deploy/Caddyfile does that, and the
alternative (self-signed, trusted on every workstation) is written down with
its cost.

docker-compose now publishes port 3000 on 127.0.0.1 only. It was on every
interface, so the same service also stood there unencrypted, and one gap in
the firewall was enough. The proxy is the only way in.

AUTH_URL is documented for the same reason a comment sits in the Caddyfile:
behind a proxy the container does not see the name the browser used, and the
callback would point somewhere nobody can reach.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 08:26:14 +02:00