Skip to content

Commit 0106107

Browse files
committed
fix: resolve model directory path in docker build
1 parent e91db67 commit 0106107

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

server/Dockerfile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# STAGE 1: AI Model Downloader (The Clean Room)
33
# --------------------------------------------------------
44
FROM node:22-slim AS model-downloader
5-
WORKDIR /models
5+
WORKDIR /app
66
RUN 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
88
RUN 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'); \
1515
FROM node:22-slim AS builder
1616
WORKDIR /app
1717

18-
# Install build tools for native modules
18+
# Install build tools
1919
RUN 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

2727
COPY 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
3130
RUN pnpm install --no-frozen-lockfile
3231

3332
COPY . .
@@ -47,13 +46,16 @@ WORKDIR /app
4746
ENV NODE_ENV=production
4847
ENV PORT=3001
4948

50-
# Copy only what is necessary
49+
# 1. Copy app code
5150
COPY --from=builder /app/dist ./dist
5251
COPY --from=builder /app/node_modules ./node_modules
5352
COPY --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

5757
USER node
5858
EXPOSE 3001
59+
60+
# Start the application
5961
CMD ["node", "dist/src/main.js"]

0 commit comments

Comments
 (0)