#!/bin/bash ## Howdy! 👋 This is the Orbital launcher script. ## Thanks for taking the time to read this. ## This script is a tiny wrapper around our docker-compose.yml, that handles ## fetching the correct docker-compose.yml, creating the directories for volumes, ## setting up user-specific .env file, and optionally launching into a specific project. ## ## If you want to do this yourself, there's some things you should know: ## 0: The docker-compose.yml is available at https://start.orbitalhq.com/docker-compose.yml ## The docker-compose is OS-dependant, as we ship our local testing tool - Nebula (https://nebula.orbitalhq.com) ## by default. Nebula can create local test environments, but it needs access to docker to do this, creating a whole ## docker-in-docker situation, with a little bit of extra networking complexity built in. ## The mechanism for doing this varies from host-to-host, so there's an OS-specific docker-compose.yml ## If you want to download it yourself, be sure to visit https://start.orbitalhq.com/docker-compose.yml in a browser, ## and we'll detect your OS. ## Alternatively, you can curl https://start.orbitalhq.com/docker-compose.yml?os=mac -o docker-compose.yml ## ..passing an os of either mac | windows | linux. ## ## 1: You MUST create the volume directories BEFORE launching Orbital. Otherwise, docker will ## create these for you, and write permissions get messed up, making it impossible for you to ## edit files locally that Orbital is reading/writing. ## That's less of an issue in a production environment, but leads to a pretty awful dev-ex when building locally. ## Scroll down to see the list of directories to create. ## ## 2: You MUST create a .env file with your UID and GID - as this is passed into docker-compose.yml so that ## Orbital doesn't run with root permissions. Again, this is to make sure that directories and files that are created ## by the Orbital process are editable locally. ## ## That's pretty much it. You can do this stuff yourself, and then use docker-compose.yml to launch the stack. ## Or, the script does it for you. ## Have a great day! set -e VERSION="1.0.0" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Helper functions error() { echo -e "${RED}✗ Error: $1${NC}" >&2 exit 1 } info() { echo -e "${BLUE}→ $1${NC}" } success() { echo -e "${GREEN}✓ $1${NC}" } # Show version if requested if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then echo "Orbital Launcher v${VERSION}" exit 0 fi # Show help if requested if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then echo "Orbital Launcher v${VERSION}" echo "" echo "Usage: curl -sSL https://start.orbitalhq.com/start.sh | bash" echo " or: curl -sSL https://start.orbitalhq.com/start.sh | bash -s -- " echo "" echo "Options:" echo " --help, -h Show this help message" echo " --version, -v Show version" echo "" echo "Example:" echo " curl -sSL https://start.orbitalhq.com/start.sh | bash -s -- https://github.com/user/repo" exit 0 fi info "Starting Orbital Launcher v${VERSION}" # Detect OS detect_os() { case "$(uname -s)" in Linux*) echo "linux";; Darwin*) echo "mac";; CYGWIN*|MINGW*|MSYS*) echo "windows";; *) error "Unsupported operating system: $(uname -s)";; esac } OS=$(detect_os) info "Detected OS: ${OS}" # Check for required tools if ! command -v docker &> /dev/null; then error "Docker is not installed. Please install Docker first: https://docs.docker.com/get-docker/" fi if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null 2>&1; then error "docker-compose is not installed. Please install docker-compose first." fi # Determine docker-compose command (newer Docker uses 'docker compose') if docker compose version &> /dev/null 2>&1; then COMPOSE_CMD="docker compose" else COMPOSE_CMD="docker-compose" fi # Create directories info "Creating directories..." mkdir -p ./config mkdir -p ./workspace mkdir -p ./prometheus_data success "Directories created" # Create .env file with current user's UID and GID info "Creating .env file with UID and GID..." cat > .env << EOF UID=$(id -u) GID=$(id -g) EOF success ".env file created with UID=$(id -u) and GID=$(id -g)" # Download docker-compose.yml info "Downloading docker-compose.yml for ${OS}..." if ! curl -fsSL "https://start.orbitalhq.com/docker-compose.yml?os=${OS}" -o docker-compose.yml; then error "Failed to download docker-compose.yml" fi success "docker-compose.yml downloaded" # Handle optional project clone parameter if [ -n "$1" ]; then info "Setting first launch action: clone=$1" export FIRST_LAUNCH_ACTION="clone=$1" fi # Start docker-compose info "Starting Orbital..." if ! $COMPOSE_CMD up -d; then error "Failed to start Orbital with docker-compose" fi # Wait for health endpoint to be ready info "Waiting for Orbital to be ready..." MAX_ATTEMPTS=60 ATTEMPT=0 check_health() { local response response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:9022/api/actuator/health 2>/dev/null || echo "000") [ "$response" = "200" ] } while ! check_health; do ATTEMPT=$((ATTEMPT + 1)) if [ $ATTEMPT -ge $MAX_ATTEMPTS ]; then error "Orbital failed to start after ${MAX_ATTEMPTS} seconds. Check logs with: ${COMPOSE_CMD} logs" fi sleep 1 echo -n "." done echo "" success "Orbital is running!" echo "" echo "======================================" echo " Open http://localhost:9022" echo "======================================" echo "" # Try to open browser automatically open_browser() { local url="http://localhost:9022" if [ "$OS" = "mac" ] && command -v open &> /dev/null; then open "$url" 2>/dev/null || true elif [ "$OS" = "linux" ] && command -v xdg-open &> /dev/null; then xdg-open "$url" 2>/dev/null || true elif [ "$OS" = "windows" ]; then if command -v cmd.exe &> /dev/null; then cmd.exe /c start "$url" 2>/dev/null || true elif command -v powershell.exe &> /dev/null; then powershell.exe -c "Start-Process '$url'" 2>/dev/null || true fi fi } open_browser info "To stop Orbital, run: ${COMPOSE_CMD} down" info "To view logs, run: ${COMPOSE_CMD} logs -f"