Local-Deploy-Modus: Stack + Migrations per pct push statt Gitea
- rapport-lxc.sh: LOCAL_STACK / LOCAL_MIGRATIONS Tarballs werden per pct push in den Container geschoben statt git clone / sync-migrations - deploy-local.sh: läuft auf dem Mac, tart die lokalen Working-Copies (SERVER-CONTAINER + APP/supabase/migrations), scp auf den Proxmox-Host, ruft rapport-lxc.sh im Local-Modus mit durchgereichten Parametern - README: Local-Deploy als empfohlener Test-Pfad dokumentiert Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,30 @@ Läuft auf der **Proxmox-VE-Host-Shell** und:
|
|||||||
|
|
||||||
## Benutzung
|
## Benutzung
|
||||||
|
|
||||||
|
### A) Local-Deploy vom Mac (zum Testen, ohne Gitea) ← empfohlen für jetzt
|
||||||
|
|
||||||
|
Schiebt die **lokalen** Working-Copies von `SERVER-CONTAINER` + den APP-Migrations
|
||||||
|
per scp/`pct push` in den Container — nichts muss vorher auf Gitea gepusht sein.
|
||||||
|
|
||||||
|
Auf deinem **Mac**, im Repo-Verzeichnis:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PVE_HOST=root@<proxmox-ip> bash deploy-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Mit Parametern:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PVE_HOST=root@192.168.1.10 RAM_MB=8192 NET_IP=192.168.1.50/24 NET_GW=192.168.1.1 \
|
||||||
|
bash deploy-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Voraussetzung: SSH-Zugang als root auf den Proxmox-Host. `deploy-local.sh` erwartet
|
||||||
|
die Schwester-Repos unter `~/RAPPORT/SERVER-CONTAINER` und `~/RAPPORT/APP`
|
||||||
|
(überschreibbar via `STACK_DIR` / `APP_DIR`).
|
||||||
|
|
||||||
|
### B) Ein-Befehl vom Gitea (wenn dieses Repo gepusht ist)
|
||||||
|
|
||||||
Auf der **Proxmox-Host-Shell** (als root):
|
Auf der **Proxmox-Host-Shell** (als root):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Executable
+72
@@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# RAPPORT Server — Local-Deploy auf einen Proxmox-Host (OHNE Gitea)
|
||||||
|
#
|
||||||
|
# Läuft auf deinem MAC. Packt die lokalen Working-Copies von SERVER-CONTAINER
|
||||||
|
# und den APP-Migrations, kopiert sie + rapport-lxc.sh per scp auf den
|
||||||
|
# Proxmox-Host und ruft dort rapport-lxc.sh im Local-Modus auf.
|
||||||
|
#
|
||||||
|
# PVE_HOST=root@192.168.1.10 bash deploy-local.sh
|
||||||
|
#
|
||||||
|
# Alle rapport-lxc.sh-Parameter (RAM_MB, NET_IP, …) werden durchgereicht:
|
||||||
|
# PVE_HOST=root@192.168.1.10 RAM_MB=8192 NET_IP=192.168.1.50/24 \
|
||||||
|
# NET_GW=192.168.1.1 bash deploy-local.sh
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ═══ Konfiguration ══════════════════════════════════════════════════════════
|
||||||
|
PVE_HOST="${PVE_HOST:-}" # root@<proxmox-ip> (Pflicht)
|
||||||
|
PVE_SSH_PORT="${PVE_SSH_PORT:-22}"
|
||||||
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
RAPPORT_ROOT="${RAPPORT_ROOT:-$(cd "$HERE/.." && pwd)}" # ~/RAPPORT
|
||||||
|
STACK_DIR="${STACK_DIR:-$RAPPORT_ROOT/SERVER-CONTAINER}"
|
||||||
|
APP_DIR="${APP_DIR:-$RAPPORT_ROOT/APP}"
|
||||||
|
MIGRATIONS_DIR="${MIGRATIONS_DIR:-$APP_DIR/supabase/migrations}"
|
||||||
|
|
||||||
|
GN='\033[0;32m'; YW='\033[0;33m'; RD='\033[0;31m'; BL='\033[1;34m'; CL='\033[0m'
|
||||||
|
msg() { echo -e "${GN}✔${CL} $*"; }
|
||||||
|
info() { echo -e "${YW}→${CL} $*"; }
|
||||||
|
die() { echo -e "${RD}✗${CL} $*" >&2; exit 1; }
|
||||||
|
|
||||||
|
echo -e "${BL}RAPPORT Server — Local-Deploy auf Proxmox${CL}"
|
||||||
|
[[ -n "$PVE_HOST" ]] || die "PVE_HOST nicht gesetzt. Beispiel: PVE_HOST=root@192.168.1.10 bash deploy-local.sh"
|
||||||
|
[[ -d "$STACK_DIR" ]] || die "STACK_DIR nicht gefunden: $STACK_DIR"
|
||||||
|
[[ -d "$MIGRATIONS_DIR" ]] || die "MIGRATIONS_DIR nicht gefunden: $MIGRATIONS_DIR"
|
||||||
|
ls "$MIGRATIONS_DIR"/*.sql >/dev/null 2>&1 || die "Keine *.sql in $MIGRATIONS_DIR"
|
||||||
|
|
||||||
|
SSH="ssh -p $PVE_SSH_PORT $PVE_HOST"
|
||||||
|
SCP="scp -P $PVE_SSH_PORT"
|
||||||
|
|
||||||
|
# ═══ 1 · Tarballs bauen ═════════════════════════════════════════════════════
|
||||||
|
TMP="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$TMP"' EXIT
|
||||||
|
STACK_TAR="$TMP/rapport-stack.tar.gz"
|
||||||
|
MIGR_TAR="$TMP/rapport-migrations.tar.gz"
|
||||||
|
|
||||||
|
info "Packe Stack aus $STACK_DIR …"
|
||||||
|
tar --exclude='.git' --exclude='node_modules' --exclude='.env' \
|
||||||
|
--exclude='volumes/db/data' --exclude='.DS_Store' \
|
||||||
|
-czf "$STACK_TAR" -C "$STACK_DIR" .
|
||||||
|
|
||||||
|
info "Packe Migrations aus $MIGRATIONS_DIR …"
|
||||||
|
tar -czf "$MIGR_TAR" -C "$MIGRATIONS_DIR" $(cd "$MIGRATIONS_DIR" && ls *.sql)
|
||||||
|
msg "Tarballs gebaut ($(du -h "$STACK_TAR" | cut -f1) Stack, $(du -h "$MIGR_TAR" | cut -f1) Migrations)."
|
||||||
|
|
||||||
|
# ═══ 2 · Auf Proxmox-Host kopieren ══════════════════════════════════════════
|
||||||
|
info "Kopiere Dateien nach $PVE_HOST:/tmp/ …"
|
||||||
|
$SCP "$STACK_TAR" "$MIGR_TAR" "$HERE/rapport-lxc.sh" "$PVE_HOST:/tmp/"
|
||||||
|
msg "Dateien übertragen."
|
||||||
|
|
||||||
|
# ═══ 3 · rapport-lxc.sh im Local-Modus auf dem Host starten ═════════════════
|
||||||
|
# Alle relevanten Parameter aus DIESER Shell an den Remote-Aufruf durchreichen.
|
||||||
|
ENV_PASS=""
|
||||||
|
for v in CTID CT_HOSTNAME CORES RAM_MB SWAP_MB DISK_GB BRIDGE STORAGE \
|
||||||
|
TMPL_STORAGE NET_IP NET_GW PASSWORD TEMPLATE; do
|
||||||
|
if [[ -n "${!v:-}" ]]; then
|
||||||
|
ENV_PASS+="$v=$(printf '%q' "${!v}") "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
info "Starte rapport-lxc.sh auf $PVE_HOST …"
|
||||||
|
echo
|
||||||
|
$SSH "LOCAL_STACK=/tmp/rapport-stack.tar.gz LOCAL_MIGRATIONS=/tmp/rapport-migrations.tar.gz ${ENV_PASS}bash /tmp/rapport-lxc.sh"
|
||||||
+38
-13
@@ -31,10 +31,17 @@ TMPL_STORAGE="${TMPL_STORAGE:-local}" # Storage für Template-Cache
|
|||||||
NET_IP="${NET_IP:-dhcp}" # dhcp ODER z.B. 192.168.1.50/24
|
NET_IP="${NET_IP:-dhcp}" # dhcp ODER z.B. 192.168.1.50/24
|
||||||
NET_GW="${NET_GW:-}" # nur bei statischer IP nötig
|
NET_GW="${NET_GW:-}" # nur bei statischer IP nötig
|
||||||
PASSWORD="${PASSWORD:-}" # root-PW im Container (leer = kein Login)
|
PASSWORD="${PASSWORD:-}" # root-PW im Container (leer = kein Login)
|
||||||
REPO_URL="${REPO_URL:-https://git.kgva.ch/karim/rapport-server.git}"
|
REPO_URL="${REPO_URL:-http://git.kgva.ch/karim/RAPPORT-SERVER.git}"
|
||||||
REPO_REF="${REPO_REF:-main}"
|
REPO_REF="${REPO_REF:-main}"
|
||||||
TEMPLATE="${TEMPLATE:-debian-12-standard}" # pveam-Template-Name (Präfix)
|
TEMPLATE="${TEMPLATE:-debian-12-standard}" # pveam-Template-Name (Präfix)
|
||||||
|
|
||||||
|
# ── Local-Modus (kein Gitea nötig) ──────────────────────────────────────────
|
||||||
|
# Wenn gesetzt, werden diese Tarballs (Pfade AUF DEM PROXMOX-HOST) per
|
||||||
|
# `pct push` in den Container geschoben statt von Gitea geklont/gesynct.
|
||||||
|
# Setzt deploy-local.sh automatisch — siehe README.
|
||||||
|
LOCAL_STACK="${LOCAL_STACK:-}" # tar.gz des SERVER-CONTAINER-Working-Copy
|
||||||
|
LOCAL_MIGRATIONS="${LOCAL_MIGRATIONS:-}" # tar.gz mit *.sql (APP/supabase/migrations)
|
||||||
|
|
||||||
# ═══ Ausgabe-Helfer ═════════════════════════════════════════════════════════
|
# ═══ Ausgabe-Helfer ═════════════════════════════════════════════════════════
|
||||||
GN='\033[0;32m'; YW='\033[0;33m'; RD='\033[0;31m'; BL='\033[1;34m'; CL='\033[0m'
|
GN='\033[0;32m'; YW='\033[0;33m'; RD='\033[0;31m'; BL='\033[1;34m'; CL='\033[0m'
|
||||||
msg() { echo -e "${GN}✔${CL} $*"; }
|
msg() { echo -e "${GN}✔${CL} $*"; }
|
||||||
@@ -110,14 +117,21 @@ pct exec "$CTID" -- bash -c '
|
|||||||
'
|
'
|
||||||
msg "Docker + Node installiert."
|
msg "Docker + Node installiert."
|
||||||
|
|
||||||
# ═══ 5 · Repo klonen ════════════════════════════════════════════════════════
|
# ═══ 5 · Stack ins Container holen (Local-Push ODER git clone) ══════════════
|
||||||
info "Klone Rapport-Stack ($REPO_URL @ $REPO_REF) …"
|
pct exec "$CTID" -- rm -rf /opt/rapport
|
||||||
pct exec "$CTID" -- bash -c "
|
pct exec "$CTID" -- mkdir -p /opt/rapport
|
||||||
set -euo pipefail
|
if [[ -n "$LOCAL_STACK" ]]; then
|
||||||
rm -rf /opt/rapport
|
[[ -f "$LOCAL_STACK" ]] || die "LOCAL_STACK '$LOCAL_STACK' nicht gefunden (auf dem Proxmox-Host)."
|
||||||
git clone --branch '$REPO_REF' --depth 1 '$REPO_URL' /opt/rapport
|
info "Schiebe lokalen Stack in den Container ($LOCAL_STACK) …"
|
||||||
"
|
pct push "$CTID" "$LOCAL_STACK" /tmp/rapport-stack.tar.gz
|
||||||
msg "Stack nach /opt/rapport geklont."
|
pct exec "$CTID" -- tar -xzf /tmp/rapport-stack.tar.gz -C /opt/rapport
|
||||||
|
pct exec "$CTID" -- rm -f /tmp/rapport-stack.tar.gz
|
||||||
|
msg "Lokaler Stack nach /opt/rapport entpackt (kein Gitea)."
|
||||||
|
else
|
||||||
|
info "Klone Rapport-Stack ($REPO_URL @ $REPO_REF) …"
|
||||||
|
pct exec "$CTID" -- git clone --branch "$REPO_REF" --depth 1 "$REPO_URL" /opt/rapport
|
||||||
|
msg "Stack nach /opt/rapport geklont."
|
||||||
|
fi
|
||||||
|
|
||||||
# ═══ 6 · Container-IP ermitteln ═════════════════════════════════════════════
|
# ═══ 6 · Container-IP ermitteln ═════════════════════════════════════════════
|
||||||
info "Ermittle Container-IP …"
|
info "Ermittle Container-IP …"
|
||||||
@@ -165,10 +179,21 @@ pct exec "$CTID" -- env CT_IP="$CT_IP" bash -c '
|
|||||||
'
|
'
|
||||||
msg ".env erzeugt (Secrets zufällig, Keys passend zum JWT_SECRET)."
|
msg ".env erzeugt (Secrets zufällig, Keys passend zum JWT_SECRET)."
|
||||||
|
|
||||||
# ═══ 8 · DB-Migrations holen ════════════════════════════════════════════════
|
# ═══ 8 · DB-Migrations bereitstellen (Local-Push ODER sync-migrations) ══════
|
||||||
info "Hole DB-Migrations aus dem App-Repo …"
|
if [[ -n "$LOCAL_MIGRATIONS" ]]; then
|
||||||
pct exec "$CTID" -- bash -c "cd /opt/rapport && bash scripts/sync-migrations.sh"
|
[[ -f "$LOCAL_MIGRATIONS" ]] || die "LOCAL_MIGRATIONS '$LOCAL_MIGRATIONS' nicht gefunden (auf dem Proxmox-Host)."
|
||||||
msg "Migrations synchronisiert."
|
info "Schiebe lokale Migrations in den Container ($LOCAL_MIGRATIONS) …"
|
||||||
|
pct exec "$CTID" -- rm -rf /opt/rapport/volumes/db/init/rapport-migrations
|
||||||
|
pct exec "$CTID" -- mkdir -p /opt/rapport/volumes/db/init/rapport-migrations
|
||||||
|
pct push "$CTID" "$LOCAL_MIGRATIONS" /tmp/rapport-migrations.tar.gz
|
||||||
|
pct exec "$CTID" -- tar -xzf /tmp/rapport-migrations.tar.gz -C /opt/rapport/volumes/db/init/rapport-migrations
|
||||||
|
pct exec "$CTID" -- rm -f /tmp/rapport-migrations.tar.gz
|
||||||
|
msg "Lokale Migrations bereitgestellt (kein Gitea)."
|
||||||
|
else
|
||||||
|
info "Hole DB-Migrations aus dem App-Repo …"
|
||||||
|
pct exec "$CTID" -- bash -c "cd /opt/rapport && bash scripts/sync-migrations.sh"
|
||||||
|
msg "Migrations synchronisiert."
|
||||||
|
fi
|
||||||
|
|
||||||
# ═══ 9 · Stack hochfahren ═══════════════════════════════════════════════════
|
# ═══ 9 · Stack hochfahren ═══════════════════════════════════════════════════
|
||||||
info "Starte Compose-Stack (Images pullen, Erststart ~1-2 Min) …"
|
info "Starte Compose-Stack (Images pullen, Erststart ~1-2 Min) …"
|
||||||
|
|||||||
Reference in New Issue
Block a user