refactor: simplify build system and improve model loading flexibility
- Remove Rollup bundling in favor of direct TypeScript compilation - Move from bundled models to dynamic model loading with configurable paths - Add Docker deployment examples and documentation - Implement robust model loader with fallback mechanisms - Update storage adapters for better cross-environment compatibility - Add comprehensive tests for model loading and package installation - Simplify package.json scripts and remove complex build configurations - Clean up deprecated demo files and old bundling scripts BREAKING CHANGE: Models are no longer bundled with the package. They are now loaded dynamically from CDN or custom paths.
This commit is contained in:
parent
89413ebec2
commit
52a43d51d4
51 changed files with 4835 additions and 8007 deletions
66
examples/docker-deployment/docker-compose.yml
Normal file
66
examples/docker-deployment/docker-compose.yml
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
brainy-app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
# Set custom models path for Brainy
|
||||
- BRAINY_MODELS_PATH=/app/models
|
||||
# Optional: Set other Brainy configuration
|
||||
- NODE_ENV=production
|
||||
volumes:
|
||||
# Optional: Mount models from host (alternative to embedding in image)
|
||||
# - ./models:/app/models:ro
|
||||
- ./logs:/app/logs
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 1G
|
||||
|
||||
# Alternative: Mount models from a separate volume
|
||||
brainy-app-with-volume:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3001:3000"
|
||||
environment:
|
||||
- BRAINY_MODELS_PATH=/models
|
||||
- NODE_ENV=production
|
||||
volumes:
|
||||
# Mount models from external volume
|
||||
- brainy-models:/models:ro
|
||||
- ./logs:/app/logs
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- model-downloader
|
||||
|
||||
# Service to download and prepare models
|
||||
model-downloader:
|
||||
image: node:24-alpine
|
||||
volumes:
|
||||
- brainy-models:/models
|
||||
command: >
|
||||
sh -c "
|
||||
if [ ! -f /models/universal-sentence-encoder/model.json ]; then
|
||||
echo 'Downloading Universal Sentence Encoder models...';
|
||||
mkdir -p /models/universal-sentence-encoder;
|
||||
# Add your model download logic here
|
||||
echo 'Models would be downloaded here in a real setup';
|
||||
else
|
||||
echo 'Models already exist';
|
||||
fi
|
||||
"
|
||||
|
||||
volumes:
|
||||
brainy-models:
|
||||
driver: local
|
||||
Loading…
Add table
Add a link
Reference in a new issue