# ── NEXUS AI — Hugging Face Spaces Dockerfile ────────────────────────────── FROM node:20 AS builder WORKDIR /app # Copy package.json and install all dependencies COPY nexus/package.json ./ RUN npm install # Copy source code COPY nexus/ ./ # Build frontend (Vite → dist/public) + backend (esbuild → dist/index.cjs) RUN npm run build # ── Production stage ────────────────────────────────────────────────────────── FROM node:20-slim # better-sqlite3 needs native build tools RUN apt-get update && apt-get install -y --no-install-recommends \ python3 make g++ \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy package.json and install production deps only COPY nexus/package.json ./ RUN npm install --omit=dev # Copy built artifacts from builder COPY --from=builder /app/dist ./dist # node:20-slim already has user 'node' with uid 1000 (required by HF Spaces) RUN chown -R node:node /app USER node # HF Spaces exposes port 7860 ENV PORT=7860 ENV NODE_ENV=production EXPOSE 7860 CMD ["node", "dist/index.cjs"]