#!/bin/bash echo "========================================" echo " Docker Build Fix Verification" echo "========================================" echo "" # Test 1: knoe-db exists echo "1. Testing knoe-db directory..." if [ -d "knoe-db" ] && [ -f "knoe-db/Dockerfile" ]; then echo " ✓ knoe-db directory with Dockerfile exists" else echo " ✗ knoe-db directory or Dockerfile missing" exit 1 fi # Test 2: Spec includes knoe-db echo "2. Testing spec file includes knoe-db..." python3 scripts/generate_spec.py > /dev/null 2>&1 if grep -q "('knoe-db', 'knoe-db')" knoe.spec; then echo " ✓ knoe-db included in spec" else echo " ✗ knoe-db not in spec" exit 1 fi # Test 3: Resource path resolution echo "3. Testing resource path resolution..." python3 << 'PYTEST' import sys from pathlib import Path sys.path.insert(0, str(Path.cwd())) from knoe.core.env import get_resource_path knoe_db = get_resource_path("knoe-db") if knoe_db.exists() and (knoe_db / "Dockerfile").exists(): print(" ✓ get_resource_path('knoe-db') works") else: print(" ✗ Resource path resolution failed") sys.exit(1) PYTEST if [ $? -ne 0 ]; then exit 1; fi # Test 4: Build directory creation echo "4. Testing .knoe/build directory creation..." python3 << 'PYTEST' import sys from pathlib import Path import shutil knoe_home = Path.home() / ".knoe" build_dir = knoe_home / "build" / "knoe-db-test" # Create and verify build_dir.mkdir(parents=True, exist_ok=True) if build_dir.exists(): print(f" ✓ Created: {build_dir}") # Cleanup shutil.rmtree(knoe_home / "build" / "knoe-db-test") else: print(" ✗ Failed to create build directory") sys.exit(1) PYTEST if [ $? -ne 0 ]; then exit 1; fi # Test 5: Copy operation echo "5. Testing build context copy..." python3 << 'PYTEST' import sys from pathlib import Path sys.path.insert(0, str(Path.cwd())) from knoe.core.env import get_resource_path from knoe.core.build_context import copy_build_context_dir knoe_home = Path.home() / ".knoe" build_dir = knoe_home / "build" / "knoe-db-test" source_dir = get_resource_path("knoe-db") try: copy_build_context_dir(source_dir, build_dir) # Verify if (build_dir / "Dockerfile").exists(): print(f" ✓ Copied build context successfully") # Cleanup # Cleanup try: import shutil shutil.rmtree(knoe_home / "build" / "knoe-db-test") except Exception: pass else: print(" ✗ Copy incomplete") sys.exit(1) except Exception as e: print(f" ✗ Copy failed: {e}") sys.exit(1) PYTEST if [ $? -ne 0 ]; then exit 1; fi echo "" echo "========================================" echo " ✓ All Docker Build Fix Tests Passed" echo "========================================" echo "" echo "The Docker build will now work correctly:" echo " • From source: Uses PROJECT_ROOT/knoe-db" echo " • From package: Copies to ~/.knoe/build/knoe-db" echo "" echo "Build directory: ~/.knoe/build/knoe-db" echo "Build command: docker build -t knoe-db:TAG ." echo ""