149 lines
4.1 KiB
Bash
149 lines
4.1 KiB
Bash
#!/bin/bash
|
||
|
||
set -e
|
||
|
||
echo "========================================="
|
||
echo "Obsidian - Quick Start"
|
||
echo "========================================="
|
||
echo ""
|
||
|
||
# Check if Docker is installed
|
||
if ! command -v docker &> /dev/null; then
|
||
echo "Error: Docker is not installed. Please install Docker first."
|
||
exit 1
|
||
fi
|
||
|
||
# Check if Docker Compose is installed
|
||
COMPOSE_CMD=""
|
||
if command -v docker-compose &> /dev/null; then
|
||
COMPOSE_CMD="docker-compose"
|
||
elif docker compose version &> /dev/null; then
|
||
COMPOSE_CMD="docker compose"
|
||
else
|
||
echo "Error: Docker Compose is not installed. Please install Docker Compose first."
|
||
exit 1
|
||
fi
|
||
|
||
# Parse command line arguments
|
||
REBUILD=false
|
||
|
||
while [[ $# -gt 0 ]]; do
|
||
case $1 in
|
||
--rebuild)
|
||
REBUILD=true
|
||
shift
|
||
;;
|
||
--help)
|
||
echo "Usage: $0 [OPTIONS]"
|
||
echo ""
|
||
echo "Options:"
|
||
echo " --rebuild Force rebuild of all containers"
|
||
echo " --help Show this help message"
|
||
echo ""
|
||
echo "NPM Registry:"
|
||
echo " Uses your machine's npm configuration automatically"
|
||
echo " npm install runs on host before Docker build"
|
||
echo ""
|
||
echo "Brings up the complete stack: database, backend API, and frontend"
|
||
echo ""
|
||
exit 0
|
||
;;
|
||
*)
|
||
echo "Unknown option: $1"
|
||
echo "Use --help for usage information"
|
||
exit 1
|
||
;;
|
||
esac
|
||
done
|
||
|
||
# Copy user's .npmrc to frontend directory if it exists
|
||
USER_NPMRC="${HOME}/.npmrc"
|
||
FRONTEND_NPMRC="frontend/.npmrc"
|
||
|
||
if [ -f "$USER_NPMRC" ]; then
|
||
echo "Copying npm registry config for Docker build..."
|
||
cp "$USER_NPMRC" "$FRONTEND_NPMRC"
|
||
echo "✓ Using custom npm registry configuration"
|
||
else
|
||
if [ -f "$FRONTEND_NPMRC" ]; then
|
||
rm -f "$FRONTEND_NPMRC"
|
||
fi
|
||
echo "ℹ Using default npm registry"
|
||
fi
|
||
echo ""
|
||
|
||
# Create .env file if it doesn't exist
|
||
if [ ! -f .env ]; then
|
||
echo "Creating .env file from .env.example..."
|
||
cp .env.example .env
|
||
echo "✓ .env file created"
|
||
else
|
||
echo "✓ .env file already exists"
|
||
fi
|
||
|
||
echo ""
|
||
|
||
# Stop existing containers if rebuild is requested
|
||
if [ "$REBUILD" = true ]; then
|
||
echo "🔄 Rebuilding containers..."
|
||
echo "Stopping existing containers..."
|
||
$COMPOSE_CMD down
|
||
echo "Removing existing images for rebuild..."
|
||
$COMPOSE_CMD down --rmi local 2>/dev/null || true
|
||
echo "Building and starting all services..."
|
||
$COMPOSE_CMD up -d --build
|
||
else
|
||
echo "Starting all services..."
|
||
$COMPOSE_CMD up -d
|
||
fi
|
||
|
||
echo ""
|
||
echo "Waiting for services to be ready..."
|
||
sleep 20
|
||
|
||
echo ""
|
||
echo "========================================="
|
||
echo "Complete Stack is running! 🚀"
|
||
echo "========================================="
|
||
echo ""
|
||
echo "Application: http://localhost:8000"
|
||
echo "API Docs: http://localhost:8000/docs"
|
||
echo "MinIO Console: http://localhost:9001"
|
||
echo " Username: minioadmin"
|
||
echo " Password: minioadmin"
|
||
echo ""
|
||
echo "To view logs: $COMPOSE_CMD logs -f"
|
||
echo "To stop: $COMPOSE_CMD down"
|
||
echo ""
|
||
echo "========================================="
|
||
echo "Testing the API..."
|
||
echo "========================================="
|
||
echo ""
|
||
|
||
# Wait a bit more for API to be fully ready
|
||
sleep 5
|
||
|
||
# Test health endpoint
|
||
if curl -s http://localhost:8000/health | grep -q "healthy"; then
|
||
echo "✓ API is healthy!"
|
||
echo ""
|
||
echo "🎯 All services are ready!"
|
||
echo ""
|
||
echo "Example: Upload a test file"
|
||
echo "----------------------------"
|
||
echo 'echo "test,data" > test.csv'
|
||
echo 'curl -X POST "http://localhost:8000/api/v1/artifacts/upload" \'
|
||
echo ' -F "file=@test.csv" \'
|
||
echo ' -F "test_name=sample_test" \'
|
||
echo ' -F "test_suite=demo" \'
|
||
echo ' -F "test_result=pass"'
|
||
echo ""
|
||
else
|
||
echo "⚠ API is not responding yet. Please wait a moment and check http://localhost:8000/health"
|
||
fi
|
||
|
||
echo "========================================="
|
||
echo "Setup complete! 🚀"
|
||
echo "Open http://localhost:8000 in your browser"
|
||
echo "========================================="
|