From b1bc4558107586a486ca1c7b03be63aafa699026 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Tue, 5 Aug 2025 20:39:39 -0700 Subject: [PATCH] fix: update Dockerfile and README to replace model extraction with download --- README.md | 14 +++++----- examples/cloud-deployments/README.md | 26 +++++++++---------- examples/cloud-deployments/aws-ecs/Dockerfile | 6 ++--- .../azure-container-instances/Dockerfile | 6 ++--- .../google-cloud-run/Dockerfile | 6 ++--- examples/docker-deployment/Dockerfile | 4 +-- examples/simple-deployment/README.md | 18 ++++++------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index cf9d4b4a..9b793e66 100644 --- a/README.md +++ b/README.md @@ -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 ./ diff --git a/examples/cloud-deployments/README.md b/examples/cloud-deployments/README.md index 4c750170..f8d42f0e 100644 --- a/examples/cloud-deployments/README.md +++ b/examples/cloud-deployments/README.md @@ -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"] ``` diff --git a/examples/cloud-deployments/aws-ecs/Dockerfile b/examples/cloud-deployments/aws-ecs/Dockerfile index ffd297c6..36f490fc 100644 --- a/examples/cloud-deployments/aws-ecs/Dockerfile +++ b/examples/cloud-deployments/aws-ecs/Dockerfile @@ -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 diff --git a/examples/cloud-deployments/azure-container-instances/Dockerfile b/examples/cloud-deployments/azure-container-instances/Dockerfile index 30da4a28..ec63fc88 100644 --- a/examples/cloud-deployments/azure-container-instances/Dockerfile +++ b/examples/cloud-deployments/azure-container-instances/Dockerfile @@ -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 diff --git a/examples/cloud-deployments/google-cloud-run/Dockerfile b/examples/cloud-deployments/google-cloud-run/Dockerfile index 7e81b937..f16f30cd 100644 --- a/examples/cloud-deployments/google-cloud-run/Dockerfile +++ b/examples/cloud-deployments/google-cloud-run/Dockerfile @@ -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 diff --git a/examples/docker-deployment/Dockerfile b/examples/docker-deployment/Dockerfile index fc534ad5..2b95bcd2 100644 --- a/examples/docker-deployment/Dockerfile +++ b/examples/docker-deployment/Dockerfile @@ -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 diff --git a/examples/simple-deployment/README.md b/examples/simple-deployment/README.md index 6b86bb25..8b88c0b7 100644 --- a/examples/simple-deployment/README.md +++ b/examples/simple-deployment/README.md @@ -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