#!/bin/bash
set -euo pipefail

SRC_ROOT="/Volumes/MacBook SD/Projekte/HebammeKrystyna"
DST_ROOT="/Volumes/docker/flask-postgres/app-hebammekrystyna"

NAS_USER="BKolb"
NAS_HOST="192.168.0.10"
CONTAINER_NAME="flask_hebammekrystyna"

echo "Starte Deployment..."

[ -d "$SRC_ROOT" ] || { echo "Quelle fehlt: $SRC_ROOT"; exit 1; }
[ -d "$DST_ROOT" ] || { echo "Ziel fehlt: $DST_ROOT"; exit 1; }

echo "Synchronisiere Projektdateien ..."
rsync -av --delete \
  --exclude '.DS_Store' \
  --exclude '._*' \
  --exclude '__pycache__/' \
  --exclude '*.pyc' \
  --exclude '*.pyo' \
  --exclude '*.log' \
  --exclude '.git/' \
  --exclude '.venv/' \
  --exclude 'venv/' \
  --exclude 'node_modules/' \
  --exclude 'files/' \
  "$SRC_ROOT/" "$DST_ROOT/"

echo "files/ wird bewusst nicht angefasst."

echo "Starte Container neu ..."
#ssh "${NAS_USER}@${NAS_HOST}" "docker restart ${CONTAINER_NAME}"

echo "Deployment abgeschlossen."