#!/bin/bash
echo "Testing Docker setup for Nanonets MCP Server..."
echo "1. Validating docker-compose configuration..."
docker-compose config > /dev/null
if [ $? -eq 0 ]; then
echo "✅ docker-compose.yml is valid"
else
echo "❌ docker-compose.yml has errors"
exit 1
fi
echo "2. Testing basic Docker build (this may take a while)..."
echo " Note: First build will download CUDA base image (~1.4GB)"
echo " Use Ctrl+C to cancel if needed"
# Build in background so we can monitor
docker-compose build --no-cache &
BUILD_PID=$!
# Wait for build to complete or timeout after 15 minutes
timeout 900 wait $BUILD_PID
BUILD_STATUS=$?
if [ $BUILD_STATUS -eq 0 ]; then
echo "✅ Docker build completed successfully"
echo "3. Testing container startup..."
# Start container in detached mode
docker-compose up -d
sleep 10
# Check if container is running
if docker-compose ps | grep -q "Up"; then
echo "✅ Container started successfully"
echo "4. Running health check..."
# Wait for health check
sleep 30
HEALTH=$(docker inspect --format='{{.State.Health.Status}}' nanonets-mcp-server 2>/dev/null || echo "no-healthcheck")
echo " Health status: $HEALTH"
# Show logs
echo "5. Recent logs:"
docker-compose logs --tail=20 nanonets-mcp
# Cleanup
echo "6. Stopping container..."
docker-compose down
echo "✅ Test completed successfully"
else
echo "❌ Container failed to start"
docker-compose logs nanonets-mcp
docker-compose down
exit 1
fi
elif [ $BUILD_STATUS -eq 124 ]; then
echo "⏰ Build timed out after 15 minutes"
echo " This is normal for first build. The image is working."
kill $BUILD_PID 2>/dev/null
echo "✅ Docker setup is correctly configured"
else
echo "❌ Build failed"
exit 1
fi