#!/bin/bash
# Docker-Befehle auf Mac Mini ausführen
MAC_MINI="benjaminadmin@192.168.178.163"
DOCKER="/usr/local/bin/docker"

case "$1" in
    ps)
        ssh $MAC_MINI "$DOCKER ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'"
        ;;
    logs)
        ssh $MAC_MINI "$DOCKER logs -f ${2:-breakpilot-pwa-backend}"
        ;;
    restart)
        ssh $MAC_MINI "cd ~/Projekte/breakpilot-pwa && $DOCKER compose restart ${2:-backend}"
        ;;
    up)
        ssh $MAC_MINI "cd ~/Projekte/breakpilot-pwa && $DOCKER compose up -d $2"
        ;;
    down)
        ssh $MAC_MINI "cd ~/Projekte/breakpilot-pwa && $DOCKER compose down"
        ;;
    build)
        ssh $MAC_MINI "cd ~/Projekte/breakpilot-pwa && $DOCKER compose build ${2:-backend}"
        ;;
    exec)
        shift
        ssh $MAC_MINI "$DOCKER exec -it breakpilot-pwa-backend $*"
        ;;
    *)
        echo "Usage: $0 {ps|logs [container]|restart [service]|up [service]|down|build [service]|exec [cmd]}"
        echo ""
        echo "Examples:"
        echo "  $0 ps              # Show running containers"
        echo "  $0 logs backend    # Follow backend logs"
        echo "  $0 restart backend # Restart backend"
        echo "  $0 build backend   # Rebuild backend image"
        echo "  $0 exec bash       # Shell in backend container"
        ;;
esac
