CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
Dockerfile57 linesDownload Raw Back to root
1# --- Stage 1: Build Frontend ---2FROM node:18-slim AS frontend-builder3WORKDIR /app/frontend4COPY frontend/package*.json ./5RUN npm install6COPY frontend/ ./7RUN npm run build8 9# --- Stage 2: Final Image ---10FROM node:18-slim11 12# Install curl for health checks13RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*14 15WORKDIR /app16 17# Install backend dependencies18COPY package*.json ./19RUN npm install --production20 21# ── CACHE BUSTER ──────────22# Bump this to force rebuild of the layers below23ARG CACHEBUST=2026-03-02.724RUN echo "Cache bust: $CACHEBUST"25# ──────────────────────────26 27# Copy backend source28COPY api/ ./api/29COPY models/ ./models/30 31# Copy built frontend from Stage 132COPY --from=frontend-builder /app/frontend/dist ./frontend/dist33 34# Pre-download Xenova/all-MiniLM-L6-v2 at BUILD time.35ENV XENOVA_CACHE_DIR=/app/.cache/xenova36RUN node -e "\37import('@xenova/transformers').then(async ({ pipeline, env }) => {\38  env.cacheDir = '/app/.cache/xenova';\39  console.log('Downloading Xenova/all-MiniLM-L6-v2 ...');\40  const p = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');\41  const t = await p('warmup', { pooling: 'mean', normalize: true });\42  console.log('Model ready — dimension:', t.data.length);\43  process.exit(0);\44}).catch(e => { console.error(e.message); process.exit(1); });"45 46# Hugging Face Spaces environment47EXPOSE 786048ENV PORT=786049ENV NODE_ENV=production50# Redis is optional — if not set, BullMQ falls back gracefully51ENV REDIS_HOST=127.0.0.152ENV REDIS_PORT=637953ENV REDIS_MAX_RETRIES=154 55# Start the Node.js API56CMD ["node", "api/app.js"]57