File size: 2,187 Bytes
da2e594
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Test script to verify Docker optimization (no n8n deps)

set -e

echo "πŸ§ͺ Testing Docker optimization..."
echo ""

# Check if nodes.db exists
if [ ! -f "data/nodes.db" ]; then
    echo "❌ ERROR: data/nodes.db not found!"
    echo "   Run 'npm run rebuild' first to create the database"
    exit 1
fi

# Build the image
echo "πŸ“¦ Building Docker image..."
DOCKER_BUILDKIT=1 docker build -t n8n-mcp:test . > /dev/null 2>&1

# Check image size
echo "πŸ“Š Checking image size..."
SIZE=$(docker images n8n-mcp:test --format "{{.Size}}")
echo "   Image size: $SIZE"

# Test that n8n is NOT in the image
echo ""
echo "πŸ” Verifying no n8n dependencies..."
if docker run --rm n8n-mcp:test sh -c "ls node_modules | grep -E '^n8n$|^n8n-|^@n8n'" 2>/dev/null; then
    echo "❌ ERROR: Found n8n dependencies in runtime image!"
    exit 1
else
    echo "βœ… No n8n dependencies found (as expected)"
fi

# Test that runtime dependencies ARE present
echo ""
echo "πŸ” Verifying runtime dependencies..."
EXPECTED_DEPS=("@modelcontextprotocol" "better-sqlite3" "express" "dotenv")
for dep in "${EXPECTED_DEPS[@]}"; do
    if docker run --rm n8n-mcp:test sh -c "ls node_modules | grep -q '$dep'" 2>/dev/null; then
        echo "βœ… Found: $dep"
    else
        echo "❌ Missing: $dep"
        exit 1
    fi
done

# Test that the server starts
echo ""
echo "πŸš€ Testing server startup..."
docker run --rm -d \
    --name n8n-mcp-test \
    -e MCP_MODE=http \
    -e AUTH_TOKEN=test-token \
    -e LOG_LEVEL=error \
    n8n-mcp:test > /dev/null 2>&1

# Wait for startup
sleep 3

# Check if running
if docker ps | grep -q n8n-mcp-test; then
    echo "βœ… Server started successfully"
    docker stop n8n-mcp-test > /dev/null 2>&1
else
    echo "❌ Server failed to start"
    docker logs n8n-mcp-test 2>&1
    exit 1
fi

# Clean up
docker rmi n8n-mcp:test > /dev/null 2>&1

echo ""
echo "πŸŽ‰ All tests passed! Docker optimization is working correctly."
echo ""
echo "πŸ“ˆ Benefits:"
echo "   - No n8n dependencies in runtime image"
echo "   - Image size: ~200MB (vs ~1.5GB with n8n)"
echo "   - Build time: ~1-2 minutes (vs ~12 minutes)"
echo "   - No version conflicts at runtime"