#!/bin/bash

# Development Environment Startup Script
# Starts the Project Image Uploader in development mode

set -euo pipefail

echo "🚀 Starting Project Image Uploader - Development Environment"
echo "   Frontend: http://localhost:3000"
echo "   Backend:  http://localhost:5001"
echo ""

# Check if production is running
if docker compose ps | grep -q "image-uploader-frontend.*Up"; then
    echo "⚠️  Production environment is running (Port 80)"
    echo "   Development will run on Port 3000 (no conflict)"
    echo ""
fi

# Start development environment
echo "📦 Starting development containers..."
docker compose -f docker/dev/docker-compose.yml up -d

echo ""
echo "✅ Development environment started!"
echo ""
echo "📊 Container Status:"
docker compose -f docker/dev/docker-compose.yml ps

echo ""
echo "🔗 Access URLs:"
echo "   📱 Frontend (Development): http://localhost:3000"
echo "   🔧 Backend API (Development): http://localhost:5001"
echo ""
echo "📝 Useful Commands:"
echo "   📋 Show logs:     docker compose -f docker/dev/docker-compose.yml logs -f"
echo "   🛑 Stop:          docker compose -f docker/dev/docker-compose.yml down"
echo "   🔄 Restart:       docker compose -f docker/dev/docker-compose.yml restart"
echo "   🏗️  Rebuild:       docker compose -f docker/dev/docker-compose.yml build --no-cache"
echo ""