#!/bin/bash

# Bangstack Docker Startup Script
echo "🚀 Starting Bangstack application..."

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

# Check if docker-compose exists
if ! command -v docker-compose &> /dev/null; then
    echo "⚠️  docker-compose not found. Using docker compose instead..."
    DOCKER_COMPOSE_CMD="docker compose"
else
    DOCKER_COMPOSE_CMD="docker-compose"
fi

# Build and start services
echo "📦 Building Docker images..."
$DOCKER_COMPOSE_CMD build

echo "🎬 Starting services..."
$DOCKER_COMPOSE_CMD up -d

echo ""
echo "✅ Application started successfully!"
echo ""
echo "📊 Service status:"
$DOCKER_COMPOSE_CMD ps

echo ""
echo "🌐 Access your application:"
echo "   Frontend: http://localhost:5173"
echo "   Backend:  http://localhost:3000"
echo ""
echo "📝 Useful commands:"
echo "   View logs:     $DOCKER_COMPOSE_CMD logs -f"
echo "   Stop services: $DOCKER_COMPOSE_CMD down"
echo "   Restart:       $DOCKER_COMPOSE_CMD restart"
echo ""
