Spaces:
Runtime error
Runtime error
| # Script to test Docker setup for FinSight application | |
| set -e | |
| echo "======================================" | |
| echo "Testing FinSight Docker Setup" | |
| echo "======================================" | |
| echo "" | |
| # Check if Docker is available | |
| if ! command -v docker &> /dev/null; then | |
| echo "β Error: Docker is not installed" | |
| exit 1 | |
| fi | |
| echo "β Docker is available" | |
| # Check if Docker Compose is available | |
| if ! docker compose version &> /dev/null; then | |
| echo "β Error: Docker Compose is not installed" | |
| exit 1 | |
| fi | |
| echo "β Docker Compose is available" | |
| # Validate docker-compose.yml | |
| echo "" | |
| echo "Validating docker-compose.yml..." | |
| if docker compose config > /dev/null 2>&1; then | |
| echo "β docker-compose.yml is valid" | |
| else | |
| echo "β Error: docker-compose.yml has syntax errors" | |
| exit 1 | |
| fi | |
| # Check if Dockerfiles exist | |
| echo "" | |
| echo "Checking Dockerfiles..." | |
| for dir in backend frontend models; do | |
| if [ -f "$dir/Dockerfile" ]; then | |
| echo "β $dir/Dockerfile exists" | |
| else | |
| echo "β Error: $dir/Dockerfile not found" | |
| exit 1 | |
| fi | |
| done | |
| # Check if .env.example exists | |
| echo "" | |
| if [ -f ".env.example" ]; then | |
| echo "β .env.example exists" | |
| else | |
| echo "β Error: .env.example not found" | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "======================================" | |
| echo "Build and Start Services" | |
| echo "======================================" | |
| echo "" | |
| echo "Building services (this may take a few minutes)..." | |
| docker compose build | |
| echo "" | |
| echo "Starting services..." | |
| docker compose up -d | |
| echo "" | |
| echo "Waiting for services to start..." | |
| sleep 10 | |
| echo "" | |
| echo "======================================" | |
| echo "Service Status" | |
| echo "======================================" | |
| docker compose ps | |
| echo "" | |
| echo "======================================" | |
| echo "Testing Service Endpoints" | |
| echo "======================================" | |
| # Test backend health | |
| echo "" | |
| echo "Testing backend (http://localhost:8000)..." | |
| # Note: /api/auth/me/ requires authentication, so we test if the service responds | |
| if curl -s http://localhost:8000/api/auth/me/ 2>&1 | grep -q "detail\|error\|Unauthorized"; then | |
| echo "β Backend is responding (authentication required as expected)" | |
| elif curl -s http://localhost:8000 > /dev/null 2>&1; then | |
| echo "β Backend is responding" | |
| else | |
| echo "β Backend is not responding" | |
| fi | |
| # Test models health | |
| echo "" | |
| echo "Testing models service (http://localhost:8001)..." | |
| if curl -s -f http://localhost:8001/health > /dev/null 2>&1; then | |
| echo "β Models service is responding" | |
| else | |
| echo "β Models service is not responding" | |
| fi | |
| # Test frontend | |
| echo "" | |
| echo "Testing frontend (http://localhost:5173)..." | |
| if curl -s -f http://localhost:5173 > /dev/null 2>&1; then | |
| echo "β Frontend is responding" | |
| else | |
| echo "β Frontend is not responding" | |
| fi | |
| echo "" | |
| echo "======================================" | |
| echo "Testing with Missing Environment Variables" | |
| echo "======================================" | |
| echo "" | |
| echo "Checking logs for environment variable errors..." | |
| if docker compose logs | grep -i "error.*environment\|missing.*variable" > /dev/null 2>&1; then | |
| echo "β Services have environment variable errors" | |
| docker compose logs | grep -i "error.*environment\|missing.*variable" | head -10 | |
| else | |
| echo "β No environment variable errors detected" | |
| fi | |
| echo "" | |
| echo "======================================" | |
| echo "β Docker Setup Test Complete" | |
| echo "======================================" | |
| echo "" | |
| echo "To stop services: docker compose down" | |
| echo "To view logs: docker compose logs -f" | |
| echo "To restart: docker compose restart" | |