#!/bin/bash
set -e

# Script to build all Docker images locally

echo "Building WCAG-ADA Docker images..."

# Get the repository root (two levels up from scripts directory)
REPO_ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
WCAG_ROOT=$(cd "$(dirname "$0")/.." && pwd)

# Set default registry if not provided
REGISTRY=${DOCKER_REGISTRY:-"wcag-ada"}

# Build API image
echo "Building API image..."
docker build \
  -f "$WCAG_ROOT/api/Dockerfile" \
  -t "$REGISTRY/api:latest" \
  "$REPO_ROOT"

# Build Worker image
echo "Building Worker image..."
docker build \
  -f "$WCAG_ROOT/worker/Dockerfile" \
  -t "$REGISTRY/worker:latest" \
  "$REPO_ROOT"

# Build Dashboard image
echo "Building Dashboard image..."
docker build \
  -f "$WCAG_ROOT/dashboard/Dockerfile" \
  -t "$REGISTRY/dashboard:latest" \
  "$REPO_ROOT"

echo "All images built successfully!"
echo ""
echo "Images created:"
echo "  - $REGISTRY/api:latest"
echo "  - $REGISTRY/worker:latest"
echo "  - $REGISTRY/dashboard:latest"