#!/bin/bash

# AAF Systems Homepage - Docker Runner Script

echo "🚀 AAF Systems Homepage Docker Setup"
echo "===================================="

# Check if Docker is running
if ! sudo docker info > /dev/null 2>&1; then
    echo "❌ Docker is not running. Please start Docker Desktop and try again."
    exit 1
fi

# Function to build and run with Docker Compose
run_with_compose() {
    echo "🔨 Building and running with Docker Compose..."
    sudo docker-compose up --build
}

# Function to build and run with Docker directly
run_with_docker() {
    echo "🔨 Building Docker image..."
    sudo docker build -t aaf-systems-homepage .
    
    echo "🚀 Running container on port 8080..."
    sudo docker run -p 8080:8080 --name aaf-systems-homepage aaf-systems-homepage
}

# Check if docker-compose is available
if command -v docker-compose &> /dev/null; then
    echo "📋 Docker Compose detected. Using docker-compose.yml..."
    run_with_compose
else
    echo "📋 Docker Compose not found. Using Docker directly..."
    run_with_docker
fi
