22# STAGE 1: AI Model Downloader (The Clean Room)
33# --------------------------------------------------------
44FROM node:22-slim AS model-downloader
5- WORKDIR /models
5+ WORKDIR /app
66RUN npm install @xenova/transformers
7- # This stage has NO project code, so it cannot crash on sharp/playwright
7+ # This script downloads the model into /app/models
88RUN node -e "const { pipeline, env } = require('@xenova/transformers'); \
9- env.localModelPath = './'; \
9+ env.localModelPath = './models '; \
1010 pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');"
1111
1212# --------------------------------------------------------
@@ -15,7 +15,7 @@ RUN node -e "const { pipeline, env } = require('@xenova/transformers'); \
1515FROM node:22-slim AS builder
1616WORKDIR /app
1717
18- # Install build tools for native modules
18+ # Install build tools
1919RUN apt-get update && apt-get install -y python3 make g++ curl && rm -rf /var/lib/apt/lists/*
2020
2121# Enable pnpm 10
@@ -26,8 +26,7 @@ RUN pnpm config set supportedArchitectures --json '{"os": ["linux"], "cpu": ["x6
2626
2727COPY package.json pnpm-lock.yaml ./
2828
29- # THE FIX: We use --no-frozen-lockfile to allow pnpm to fix the 'sharp'
30- # mismatch for Linux during the build.
29+ # Allow pnpm to resolve the 'sharp' binary mismatch
3130RUN pnpm install --no-frozen-lockfile
3231
3332COPY . .
@@ -47,13 +46,16 @@ WORKDIR /app
4746ENV NODE_ENV=production
4847ENV PORT=3001
4948
50- # Copy only what is necessary
49+ # 1. Copy app code
5150COPY --from=builder /app/dist ./dist
5251COPY --from=builder /app/node_modules ./node_modules
5352COPY --from=builder /app/package.json ./package.json
54- # Bring in the AI models from the "Clean Room" stage
55- COPY --from=model-downloader /models/Xenova ./models/Xenova
53+
54+ # 2. Copy the AI models from Stage 1 (Simplified path)
55+ COPY --from=model-downloader /app/models ./models
5656
5757USER node
5858EXPOSE 3001
59+
60+ # Start the application
5961CMD ["node" , "dist/src/main.js" ]
0 commit comments