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 d3ff38174c
commit b1bc455810
7 changed files with 40 additions and 40 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ This is the **simplest possible** way to deploy Brainy applications with embedde
## 🎯 How It Works
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.
4. **Models load automatically** - zero configuration needed!
@ -20,15 +20,15 @@ npm install @soulcraft/brainy-models
### Step 2: Create Dockerfile
```dockerfile
FROM node:24-alpine AS builder
FROM node:24-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
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
FROM node:24-alpine AS production
FROM node:24-slim AS production
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production --omit=optional
@ -62,7 +62,7 @@ az container create --image your-image
## 🏗️ 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
3. Creates marker file for runtime detection
4. Brainy automatically finds models at startup
@ -74,7 +74,7 @@ After deployment, check your logs for:
**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
Using custom model path for Docker/production deployment
```
@ -148,7 +148,7 @@ export default {
### "Models not found" error
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`
### Memory issues
@ -176,9 +176,9 @@ Increase container memory:
## 🎉 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
- ✅ Zero configuration required
- ✅ Maximum performance