Spaces:
Runtime error
Runtime error
File size: 3,626 Bytes
1a2b901 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #!/bin/bash
# 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"
|