fix: update Dockerfile and README to replace model extraction with download

This commit is contained in:
David Snelling 2025-08-05 20:39:39 -07:00
parent c77a0b0912
commit 3afb765393
7 changed files with 40 additions and 40 deletions

View file

@ -510,7 +510,7 @@ Brainy automatically detects and optimizes for:
```dockerfile ```dockerfile
# One line extracts models automatically during build # One line extracts models automatically during build
RUN npm run extract-models RUN npm run download-models
# Deploy anywhere: Google Cloud, AWS, Azure, Cloudflare, etc. # Deploy anywhere: Google Cloud, AWS, Azure, Cloudflare, etc.
``` ```
@ -712,7 +712,7 @@ const brainy = createAutoBrainy({
2. **Add to your Dockerfile:** 2. **Add to your Dockerfile:**
```dockerfile ```dockerfile
# Extract models during build (zero configuration!) # Extract models during build (zero configuration!)
RUN npm run extract-models RUN npm run download-models
# Include models in final image # Include models in final image
COPY --from=builder /app/models ./models COPY --from=builder /app/models ./models
@ -730,15 +730,15 @@ const brainy = createAutoBrainy({
### Universal Dockerfile Template ### Universal Dockerfile Template
```dockerfile ```dockerfile
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci RUN npm ci
COPY . . COPY . .
RUN npm run extract-models # ← Automatic model extraction RUN npm run download-models # ← Automatic model download
RUN npm run build RUN npm run build
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production --omit=optional RUN npm ci --only=production --omit=optional
@ -1241,7 +1241,7 @@ export const searchHandler = async (req, res) => {
```dockerfile ```dockerfile
# Dockerfile # Dockerfile
FROM node:20-alpine FROM node:24-slim
USER node USER node
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
@ -1337,7 +1337,7 @@ serve(async (req) => {
### Docker Container ### Docker Container
```dockerfile ```dockerfile
FROM node:20-alpine FROM node:24-slim
USER node USER node
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./

View file

@ -4,8 +4,8 @@ This guide provides **zero-configuration** deployment examples for Brainy across
## 🚀 How It Works ## 🚀 How It Works
1. **Automatic Model Extraction**: The `scripts/extract-models.js` script runs during Docker build 1. **Automatic Model Download**: The `scripts/download-models.cjs` script runs during Docker build
2. **Auto-Detection**: Brainy automatically finds extracted models at runtime 2. **Auto-Detection**: Brainy automatically finds downloaded models at runtime
3. **Universal Compatibility**: Works across Google Cloud, AWS, Azure, Cloudflare, and others 3. **Universal Compatibility**: Works across Google Cloud, AWS, Azure, Cloudflare, and others
4. **Zero Configuration**: No environment variables or custom paths needed 4. **Zero Configuration**: No environment variables or custom paths needed
@ -14,14 +14,14 @@ This guide provides **zero-configuration** deployment examples for Brainy across
### Google Cloud Run ### Google Cloud Run
```dockerfile ```dockerfile
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY . . COPY . .
RUN node scripts/extract-models.js # ← Automatic model extraction RUN node scripts/download-models.cjs # ← Automatic model download
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production --omit=optional RUN npm ci --only=production --omit=optional
@ -47,7 +47,7 @@ FROM public.ecr.aws/lambda/nodejs:24
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY . . COPY . .
RUN node scripts/extract-models.js # ← Automatic model extraction RUN node scripts/download-models.cjs # ← Automatic model download
CMD ["index.handler"] CMD ["index.handler"]
``` ```
@ -64,14 +64,14 @@ aws lambda create-function \
### AWS ECS/Fargate ### AWS ECS/Fargate
```dockerfile ```dockerfile
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY . . COPY . .
RUN node scripts/extract-models.js # ← Automatic model extraction RUN node scripts/download-models.cjs # ← Automatic model download
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app
COPY --from=builder /app/models ./models # ← Models included COPY --from=builder /app/models ./models # ← Models included
# ... rest of Dockerfile # ... rest of Dockerfile
@ -97,14 +97,14 @@ Deploy with ECS task definition:
### Azure Container Instances ### Azure Container Instances
```dockerfile ```dockerfile
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY . . COPY . .
RUN node scripts/extract-models.js # ← Automatic model extraction RUN node scripts/download-models.cjs # ← Automatic model download
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app
COPY --from=builder /app/models ./models # ← Models included COPY --from=builder /app/models ./models # ← Models included
ENV PORT=80 ENV PORT=80
@ -152,7 +152,7 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY . . COPY . .
RUN node scripts/extract-models.js # ← Automatic model extraction RUN node scripts/download-models.cjs # ← Automatic model download
CMD ["node", "dist/server.js"] CMD ["node", "dist/server.js"]
``` ```

View file

@ -1,7 +1,7 @@
# AWS ECS Dockerfile with Auto-Extracted Models # AWS ECS Dockerfile with Auto-Extracted Models
# Standard Node.js container optimized for ECS # Standard Node.js container optimized for ECS
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
@ -15,10 +15,10 @@ RUN npm ci --only=production && npm cache clean --force
COPY . . COPY . .
# Extract models using our automatic script # Extract models using our automatic script
RUN node scripts/extract-models.js RUN node scripts/download-models.cjs
# Production stage # Production stage
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app

View file

@ -1,7 +1,7 @@
# Azure Container Instances Dockerfile with Auto-Extracted Models # Azure Container Instances Dockerfile with Auto-Extracted Models
# Optimized for Azure Container Instances # Optimized for Azure Container Instances
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
@ -15,10 +15,10 @@ RUN npm ci --only=production && npm cache clean --force
COPY . . COPY . .
# Extract models using our automatic script # Extract models using our automatic script
RUN node scripts/extract-models.js RUN node scripts/download-models.cjs
# Production stage # Production stage
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app

View file

@ -1,7 +1,7 @@
# Google Cloud Run Dockerfile with Auto-Extracted Models # Google Cloud Run Dockerfile with Auto-Extracted Models
# Optimized for Cloud Run's requirements and constraints # Optimized for Cloud Run's requirements and constraints
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
@ -15,10 +15,10 @@ RUN npm ci --only=production && npm cache clean --force
COPY . . COPY . .
# Extract models using our automatic script # Extract models using our automatic script
RUN node scripts/extract-models.js RUN node scripts/download-models.cjs
# Production stage # Production stage
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app

View file

@ -1,5 +1,5 @@
# Multi-stage Dockerfile for Brainy with embedded models # Multi-stage Dockerfile for Brainy with embedded models
FROM node:24-alpine AS builder FROM node:24-slim AS builder
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
@ -26,7 +26,7 @@ RUN mkdir -p /app/models && \
fi fi
# Production stage # Production stage
FROM node:24-alpine AS production FROM node:24-slim AS production
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app

View file

@ -5,7 +5,7 @@ This is the **simplest possible** way to deploy Brainy applications with embedde
## 🎯 How It Works ## 🎯 How It Works
1. **Install @soulcraft/brainy-models** in your project 1. **Install @soulcraft/brainy-models** in your project
2. **Add one line** to your Dockerfile: `RUN npm run extract-models` 2. **Add one line** to your Dockerfile: `RUN npm run download-models`
3. **Deploy anywhere** - Google Cloud, AWS, Azure, Cloudflare, etc. 3. **Deploy anywhere** - Google Cloud, AWS, Azure, Cloudflare, etc.
4. **Models load automatically** - zero configuration needed! 4. **Models load automatically** - zero configuration needed!
@ -20,15 +20,15 @@ npm install @soulcraft/brainy-models
### Step 2: Create Dockerfile ### Step 2: Create Dockerfile
```dockerfile ```dockerfile
FROM node:24-alpine AS builder FROM node:24-slim AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci RUN npm ci
COPY . . COPY . .
RUN npm run extract-models # ← This line extracts models automatically! RUN npm run download-models # ← This line downloads models automatically!
RUN npm run build RUN npm run build
FROM node:24-alpine AS production FROM node:24-slim AS production
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production --omit=optional RUN npm ci --only=production --omit=optional
@ -62,7 +62,7 @@ az container create --image your-image
## 🏗️ What Happens During Build ## 🏗️ What Happens During Build
1. `npm run extract-models` finds @soulcraft/brainy-models 1. `npm run download-models` finds @soulcraft/brainy-models
2. Copies models to `./models` directory 2. Copies models to `./models` directory
3. Creates marker file for runtime detection 3. Creates marker file for runtime detection
4. Brainy automatically finds models at startup 4. Brainy automatically finds models at startup
@ -74,7 +74,7 @@ After deployment, check your logs for:
**Success (what you want to see)**: **Success (what you want to see)**:
``` ```
🎯 Auto-detected extracted models at: /app/models 🎯 Auto-detected downloaded models at: /app/models
✅ Successfully loaded model from custom directory ✅ Successfully loaded model from custom directory
Using custom model path for Docker/production deployment Using custom model path for Docker/production deployment
``` ```
@ -148,7 +148,7 @@ export default {
### "Models not found" error ### "Models not found" error
1. **Check package.json**: Ensure `@soulcraft/brainy-models` is in `dependencies` 1. **Check package.json**: Ensure `@soulcraft/brainy-models` is in `dependencies`
2. **Check Dockerfile**: Ensure `RUN npm run extract-models` runs 2. **Check Dockerfile**: Ensure `RUN npm run download-models` runs
3. **Check image**: `docker run -it your-image ls -la /app/models` 3. **Check image**: `docker run -it your-image ls -la /app/models`
### Memory issues ### Memory issues
@ -176,9 +176,9 @@ Increase container memory:
## 🎉 That's It! ## 🎉 That's It!
With just `npm install @soulcraft/brainy-models` and `RUN npm run extract-models` in your Dockerfile, you get: With just `npm install @soulcraft/brainy-models` and `RUN npm run download-models` in your Dockerfile, you get:
- ✅ Automatic model extraction - ✅ Automatic model download
- ✅ Universal cloud compatibility - ✅ Universal cloud compatibility
- ✅ Zero configuration required - ✅ Zero configuration required
- ✅ Maximum performance - ✅ Maximum performance