- docker rm -f trainingsplan vor docker compose up -d behebt den Namenskonflikt mit einem alten Container (Daten-Ordner bleibt erhalten) - Healthcheck prueft /api/meta statt des nicht existierenden /api/data
46 lines
1.4 KiB
Bash
Executable File
46 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Deploy Trainingsplan: aktuellen Stand aus dem Gitea-Repo holen und neu bauen.
|
|
# Das Repo ist oeffentlich, es wird kein Zugangsschluessel gebraucht.
|
|
#
|
|
# Aufruf im CasaOS-Terminal:
|
|
# bash /DATA/AppData/trainingsplan/deploy.sh
|
|
|
|
set -euo pipefail
|
|
|
|
APP_DIR="/DATA/AppData/trainingsplan"
|
|
ORIGIN="https://git.somantis.net/J4stMarkus/trainingsplan.git"
|
|
|
|
cd "$APP_DIR" || { echo "FEHLER: $APP_DIR existiert nicht." >&2; exit 1; }
|
|
|
|
if [ -d .git ]; then
|
|
git remote set-url origin "$ORIGIN" 2>/dev/null \
|
|
|| git remote add origin "$ORIGIN"
|
|
else
|
|
git init -q
|
|
git remote add origin "$ORIGIN"
|
|
fi
|
|
|
|
echo "==> Pull main von Gitea"
|
|
git fetch -q origin main
|
|
git reset --hard -q origin/main
|
|
|
|
echo "==> Docker build (--no-cache) + up"
|
|
docker compose build --no-cache
|
|
|
|
# Alten Container gleichen Namens entfernen (falls er aus einem frueheren
|
|
# Projekt/Ordner stammt). Der gebundene Daten-Ordner
|
|
# (/DATA/AppData/trainingsplan/data) bleibt dabei unberuehrt - die SQLite-DB
|
|
# ueberlebt also Container-Removal und Rebuild.
|
|
docker rm -f trainingsplan 2>/dev/null || true
|
|
|
|
docker compose up -d
|
|
|
|
# ---------- Kurzer Healthcheck ----------
|
|
sleep 2
|
|
if curl -s -o /dev/null -w "%{http_code}" "http://127.0.0.1:8080/api/meta" | grep -q 200; then
|
|
echo "OK: Trainingsplan laeuft auf http://<server>:8080/"
|
|
else
|
|
echo "WARNUNG: Container gestartet, aber /api/meta antwortet noch nicht."
|
|
echo " Pruefe: docker compose ps / docker compose logs"
|
|
fi
|