54 lines
2.3 KiB
Markdown
54 lines
2.3 KiB
Markdown
# Deploy-Pipeline
|
||
|
||
## Überblick
|
||
|
||
Bei jedem **Push auf `main`** in git.hocks.eu (ah-admin/Mieterportal) läuft
|
||
automatisch die Pipeline **„Build & Deploy"** (sichtbar unter
|
||
`https://git.hocks.eu/ah-admin/Mieterportal/actions`):
|
||
|
||
1. **Checkout** – Quellstand des Pushes
|
||
2. **Abhängigkeiten installieren** – `npm ci`
|
||
3. **Typecheck** – `tsc --noEmit` (bricht den Deploy bei Typfehlern ab)
|
||
4. **Anleitungs-Stand aktualisieren** – `anleitung-meta.mjs` schreibt Hash/Datum
|
||
in die Anleitungsseite (Hash aus `GITHUB_SHA`, da im Job-Container kein `.git` liegt)
|
||
5. **Build** – `npm run build`
|
||
6. **Deploy** – Inhalt von `dist/` wird nach `/opt/mieterportal/dist` kopiert
|
||
(Bind-Mount des `mp-portal`-nginx-Containers; **Dateien kopieren, nie `mv`**,
|
||
sonst folgt der Mount dem alten Inode)
|
||
7. **Health-Check** – `https://mieterportal.hocks.eu/` muss antworten,
|
||
sonst schlägt der Lauf fehl
|
||
|
||
Die Anleitungsseiten (Mieter + Verwaltung) sind Teil des Builds und werden damit
|
||
**mit jedem Deploy automatisch auf den aktuellen Stand gebracht**.
|
||
|
||
## Infrastruktur auf dem VPS (hocks.eu)
|
||
|
||
- **Gitea** (Container `gitea`) – hostet das Repo, stellt die Actions-API bereit
|
||
- **act-runner** (Container `act-runner`, Compose: `/opt/act-runner/docker-compose.yml`,
|
||
Config: `/opt/act-runner/config.yaml`) – registriert als `hocks-vps-runner`,
|
||
führt Jobs in `node:22-alpine`-Containern aus
|
||
- **Volume-Whitelist:** Der Job-Container mountet `/opt/mieterportal` als `/mp`
|
||
(Eintrag `container.valid_volumes` im Runner; im Workflow als
|
||
`options: -v /opt/mieterportal:/mp`)
|
||
|
||
## Manueller Deploy (Notfall)
|
||
|
||
Pipeline kaputt oder Runner offline:
|
||
|
||
```bash
|
||
npm ci && npx tsc --noEmit && npm run build
|
||
pscp -r dist root@hocks.eu:/tmp/dist-neu
|
||
ssh root@hocks.eu "rm -rf /opt/mieterportal/dist/* && cp -a /tmp/dist-neu/. /opt/mieterportal/dist/"
|
||
```
|
||
|
||
## Wartung
|
||
|
||
- **Runner-Logs:** `docker logs act-runner`
|
||
- **Runner neu starten:** `cd /opt/act-runner && docker compose restart`
|
||
- **Neuen Runner registrieren:** Registrierungstoken erzeugen
|
||
(Gitea Admin → Actions → Runners, oder API
|
||
`POST /api/v1/admin/actions/runners/registration-token`), dann als
|
||
`GITEA_RUNNER_REGISTRATION_TOKEN` in die Compose-Datei eintragen,
|
||
`data/.runner` löschen und Container neu starten. Token danach wieder aus
|
||
der Compose-Datei entfernen.
|