Add Alpine Linux support via stub onnxruntime-node module

The @xenova/transformers package unconditionally imports both
onnxruntime-node and onnxruntime-web at module load time. This
causes immediate failure on Alpine Linux (musl libc) because
onnxruntime-node requires glibc.

Solution: Created alpine:setup script that replaces onnxruntime-node
with a stub module after npm install. The transformers library will
automatically fall back to onnxruntime-web (WASM backend).

Usage on Alpine:
  npm install
  npm run alpine:setup
  npm run build
  npm run index:all

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-11-23 10:41:05 -06:00
parent dfccbf110a
commit 28f5d83d67
3 changed files with 41 additions and 0 deletions

View File

@ -44,6 +44,18 @@ npm install
npm run build
```
### Alpine Linux Setup
If you're running on Alpine Linux (musl libc), you need an additional setup step after installing dependencies:
```bash
npm install
npm run alpine:setup
npm run build
```
This removes the incompatible `onnxruntime-node` native module and configures the system to use the WASM backend instead. The WASM backend is slightly slower but works on all platforms.
## Initial Setup
Before using the MCP server, you need to index the Babylon.js repositories. This is a one-time setup process.

View File

@ -13,6 +13,7 @@
"test:ui": "vitest --ui",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage",
"alpine:setup": "sh scripts/alpine-setup.sh",
"index:docs": "tsx scripts/index-docs.ts",
"index:api": "tsx scripts/index-api.ts",
"index:source": "tsx scripts/index-source.ts",

28
scripts/alpine-setup.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# Alpine Linux setup script
# Removes onnxruntime-node to prevent glibc dependency errors
# The transformers library will fall back to onnxruntime-web (WASM)
echo "Removing onnxruntime-node for Alpine Linux compatibility..."
# Remove the onnxruntime-node directory
rm -rf node_modules/onnxruntime-node
# Create a stub module so imports don't fail
mkdir -p node_modules/onnxruntime-node
cat > node_modules/onnxruntime-node/package.json << 'EOF'
{
"name": "onnxruntime-node",
"version": "0.0.0-stub",
"main": "index.js",
"type": "module"
}
EOF
cat > node_modules/onnxruntime-node/index.js << 'EOF'
// Stub module for Alpine Linux
// @xenova/transformers will use onnxruntime-web instead
export default {};
EOF
echo "✓ Alpine Linux setup complete - WASM backend will be used"