#!/bin/bash

# Startup script for MerchantsOfHope.org recruiting platform
# This script helps run the application using Docker Compose

set -e

echo "MerchantsOfHope.org Recruiting Platform"
echo "======================================="

# Check if Docker is available
if ! command -v docker &> /dev/null; then
    echo "Error: Docker is not installed or not in PATH"
    exit 1
fi

# Check if docker-compose is available
if ! command -v docker-compose &> /dev/null; then
    echo "Error: Docker Compose is not installed or not in PATH"
    exit 1
fi

# Get the directory of this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo "Starting MerchantsOfHope.org recruiting platform..."
echo "Project directory: $SCRIPT_DIR"

# Build and start the containers
echo "Building and starting containers..."
docker-compose up --build -d

echo "Containers started successfully!"
echo "The application will be available at http://localhost:17000"
echo "Keycloak admin interface will be available at http://localhost:8080"
echo ""
echo "To view logs: docker-compose logs -f"
echo "To stop: docker-compose down"