Files
wibosim/scripts/deploy-pi.sh
T
db9979andClaude Opus 5.5 e93135cc83 Betrieb: CI mit Multi-Arch-Image, Rollback, HTTPS-Profil, API-Doku
- GitHub Actions: Tests, danach Image für amd64/arm64 nach ghcr.io (latest + sha-Tags)
- docker-compose: fertiges Image mit Build-Fallback, Versions-Tag, Caddy-Profil „https“ (tls internal)
- deploy-pi.sh holt das Image (Fallback: lokal bauen) und prüft die Gesundheit; rollback.sh für Version oder Datenbanksicherung
- Dockerfile mit Versionslabel, ohne Testdateien
- docs/API.md: vollständige REST/WebSocket-Schnittstelle; KONZEPT: Architektur, Sicherheit, Roadmap aktualisiert

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUhQVoPUusUzxgxLWkK
2026-12-03 14:00:36 +00:00

53 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Deployment auf dem Raspberry Pi (192.168.178.21).
# Einmalig auf dem Pi ausführen: curl -fsSL https://raw.githubusercontent.com/db9979/wibosim/main/scripts/deploy-pi.sh | bash
# Danach für Updates einfach erneut ausführen (oder: cd ~/wibosim && docker compose pull && docker compose up -d).
set -euo pipefail
REPO="${REPO:-https://github.com/db9979/wibosim.git}"
DIR="${DIR:-$HOME/wibosim}"
if ! command -v docker >/dev/null; then
echo ">> Docker wird installiert …"
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker "$USER"
echo ">> Docker installiert. Bitte einmal ab- und wieder anmelden und das Skript erneut starten."
exit 0
fi
if [ -d "$DIR/.git" ]; then
echo ">> Aktualisiere $DIR"; git -C "$DIR" pull --ff-only
else
echo ">> Klone nach $DIR"; git clone "$REPO" "$DIR"
fi
cd "$DIR"
[ -f .env ] || cp .env.example .env
# Vor dem Update: Version merken (für scripts/rollback.sh)
PREV=$(docker inspect --format '{{index .Config.Labels "org.opencontainers.image.version"}}' wibosim 2>/dev/null || true)
[ -n "$PREV" ] && echo "$PREV" > .last-version
echo ">> Hole fertiges Image (amd64/arm64) …"
if docker compose pull wibosim 2>/dev/null; then
docker compose up -d
else
echo ">> Kein fertiges Image erreichbar – baue lokal (dauert auf dem Pi einige Minuten) …"
docker compose up -d --build
fi
docker image prune -f >/dev/null
echo ">> Warte auf den Gesundheitscheck …"
for i in $(seq 1 30); do
if curl -fsS http://127.0.0.1:8086/api/health >/dev/null 2>&1; then OK=1; break; fi
sleep 2
done
IP=$(hostname -I | awk '{print $1}')
echo
if [ "${OK:-0}" = 1 ]; then
echo "✅ WiBoSim läuft: http://${IP}:8086"
else
echo "⚠️ Gesundheitscheck noch nicht erfolgreich – Logs prüfen: docker compose logs --tail 100"
fi
echo " Admin-Menü: http://${IP}:8086/admin"
echo " Admin einrichten: Einrichtungscode steht im Log → docker compose logs wibosim | grep Einrichtungscode"
echo " Zurück auf die vorige Version: scripts/rollback.sh"