#!/bin/bash

# FCB Looper Docker Launcher Script
# Usage: ./run <service> [additional args...]

set -e

# Get current user's UID and GID
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)

# Get KVM group ID for hardware acceleration
export KVM_GID=$(getent group kvm | cut -d: -f3)

# Check if service name is provided
if [ $# -eq 0 ]; then
    echo "Usage: $0 <service> [additional args...]"
    echo "Available services:"
    echo "  disk-image         - Yocto build environment, builds disk-image if no other arguments are provided"
    echo "  qemu-server        - Starts the qemu VNC server"
    exit 1
fi

SERVICE=$1
shift

docker compose run --remove-orphans --rm "$SERVICE" "$@"