#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

cd "$ROOT_DIR"

mkdir -p docker/floci/generated
chmod 777 docker/floci/generated

if ! command -v docker >/dev/null 2>&1; then
  echo "Docker no esta instalado." >&2
  exit 1
fi

if ! docker compose version >/dev/null 2>&1; then
  echo "Docker Compose no esta disponible." >&2
  exit 1
fi

docker compose -f docker-compose.local.yml up -d floci

cat <<EOF

Floci listo en http://localhost:4566

Variables sugeridas para AWS CLI / SDK:

  export AWS_ENDPOINT_URL=http://localhost:4566
  export AWS_DEFAULT_REGION=us-east-1
  export AWS_ACCESS_KEY_ID=test
  export AWS_SECRET_ACCESS_KEY=test

Verifica Cognito:

  aws cognito-idp list-user-pools --max-results 10 --endpoint-url \$AWS_ENDPOINT_URL
  aws cognito-idp list-users --user-pool-id us-east-1_BaseAdminWeb --endpoint-url \$AWS_ENDPOINT_URL

Variables generadas (tras el bootstrap):

  cat ./docker/floci/generated/cognito.local.env

EOF