#!/bin/bash
# ── VoxelRealm — Deploy to Raspberry Pi ─────────────────────────────────────
# Usage: ./deploy.sh [user@pi-ip]
# Default: pi@homoverbi.org

set -e

SERVER="${1:-pi@homoverbi.org}"
REMOTE_DIR="/srv/voxelrealm"

echo "==> Syncing to $SERVER:$REMOTE_DIR ..."
rsync -avz --delete \
    --exclude='build2/' \
    --exclude='build-windows/' \
    --exclude='saves/' \
    --exclude='save/' \
    --exclude='src/' \
    --exclude='tools/' \
    --exclude='mingw-deps/' \
    --exclude='**/__pycache__/' \
    --exclude='website/downloads/*.exe' \
    --exclude='website/downloads/*.AppImage' \
    ./ "$SERVER:$REMOTE_DIR/"

echo "==> Building and starting ..."
ssh "$SERVER" "cd $REMOTE_DIR && docker compose up -d --build"

echo ""
echo "Done! https://homoverbi.org"
