2026-11-19 02:12:53 +01:00
|
|
|
|
# Robot Clash – Deploy auf den Hetzner-Server (Dev/Test-System)
|
2026-11-18 15:18:38 +01:00
|
|
|
|
|
2026-11-19 02:12:53 +01:00
|
|
|
|
Spiel + API laufen auf **einem** Server unter `https://roboclash.michael-media.de/` (Caddy macht TLS automatisch und
|
|
|
|
|
|
leitet an den Node-Dienst weiter, WebSocket `/ws` inklusive). Alle Befehle aus dem Repo-Root in **Git Bash**
|
|
|
|
|
|
(Windows) oder einer Linux-Shell; SSH-Zugang `root@roboclash.michael-media.de` per Schlüssel.
|
2026-11-18 15:18:38 +01:00
|
|
|
|
|
2026-11-19 02:12:53 +01:00
|
|
|
|
## Aufbau auf dem Server
|
2026-11-18 15:18:38 +01:00
|
|
|
|
|
|
|
|
|
|
```
|
2026-11-19 02:12:53 +01:00
|
|
|
|
/opt/robotclash/
|
|
|
|
|
|
releases/<zeit>-<commit>/ je Deploy ein vollständiges Release (game/, server/, admin/), die letzten 5 bleiben
|
|
|
|
|
|
current -> releases/... aktives Release (Symlink)
|
|
|
|
|
|
shared/.env PORT, JWT_SECRET, DB_FILE (bleibt über Deploys erhalten, nur root/Dienst lesbar)
|
|
|
|
|
|
shared/data.sqlite Datenbank
|
|
|
|
|
|
backups/ pre-<release>.sqlite vor jedem Deploy, daily-<datum>.sqlite (cron, 14 Tage)
|
2026-11-18 15:18:38 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-11-19 02:12:53 +01:00
|
|
|
|
Dienst `robotclash` (systemd) läuft als eigener Nutzer `robotclash`, darf nur nach `shared/` schreiben.
|
|
|
|
|
|
|
|
|
|
|
|
## 1) Server einrichten (einmal; erneut ausführen schadet nicht)
|
2026-11-18 15:18:38 +01:00
|
|
|
|
|
2026-11-19 02:12:53 +01:00
|
|
|
|
```bash
|
|
|
|
|
|
scp server/deploy/setup.sh root@roboclash.michael-media.de:/root/
|
|
|
|
|
|
ssh root@roboclash.michael-media.de "bash /root/setup.sh roboclash.michael-media.de"
|
2026-11-18 15:18:38 +01:00
|
|
|
|
```
|
2026-11-19 02:12:53 +01:00
|
|
|
|
|
|
|
|
|
|
Installiert Node 24 + Caddy, legt Nutzer, Ordner, Dienst, Firewall und Backup an. Ein altes Layout
|
|
|
|
|
|
(`/opt/robotclash/server`, `/game`) wird nach `/opt/robotclash/legacy-<datum>/` verschoben, `JWT_SECRET` übernommen.
|
|
|
|
|
|
|
|
|
|
|
|
## 2) Deployen
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
bash server/deploy/deploy.sh # aktuellen Commit (HEAD) ausrollen
|
|
|
|
|
|
bash server/deploy/deploy.sh --reset-db # ... und DB frisch aufsetzen (Testkonten michi / benni)
|
|
|
|
|
|
bash server/deploy/deploy.sh --ref <commit> # einen bestimmten Stand (z. B. zurück auf einen alten)
|
2026-11-18 15:18:38 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-11-19 02:12:53 +01:00
|
|
|
|
Es wird **nur Committetes** ausgerollt (`git archive`). Ablauf: hochladen → `npm ci` → DB-Backup → Dienst stoppen →
|
|
|
|
|
|
(optional Reset) → `current` umschalten → starten → `/healthz` muss den neuen Commit melden, sonst **automatisch
|
|
|
|
|
|
zurück** auf das vorige Release.
|
|
|
|
|
|
|
|
|
|
|
|
## Testkonten (nur Test-System, siehe CLAUDE.md)
|
|
|
|
|
|
|
|
|
|
|
|
`michi` / `Michi2000!` und `benni` / `Benni2000!` – beide Admin (Dev-Münzen, `/admin/`). Kommen per `--reset-db`.
|
2026-11-18 15:18:38 +01:00
|
|
|
|
|
|
|
|
|
|
## Logs / Status
|
2026-11-19 02:12:53 +01:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
ssh root@roboclash.michael-media.de "systemctl status robotclash; journalctl -u robotclash -n 50"
|
|
|
|
|
|
curl -s https://roboclash.michael-media.de/healthz
|
2026-11-18 15:18:38 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-11-19 02:12:53 +01:00
|
|
|
|
## Später (Plan)
|
|
|
|
|
|
|
|
|
|
|
|
Eigener SSH-Nutzer `deploy` statt root (P3-1), Deploy aus Gitea Actions bei Push auf `main` (P3-6), Produktion als
|
|
|
|
|
|
zweite Umgebung erst nach T-4.
|