# ---- Build stage ---- FROM node:20-slim AS builder WORKDIR /app # Copy lockfile + manifest first for layer-cache efficiency COPY package.json package-lock.json ./ # Reproducible install (includes devDeps needed for vite build) RUN npm ci # Copy source COPY . . # Build the React frontend → dist/ RUN npm run build # ---- Runtime stage ---- FROM node:20-slim WORKDIR /app COPY package.json package-lock.json ./ # Production + tsx needed for server runtime RUN npm ci # Bring in the compiled frontend and server source COPY --from=builder /app/dist ./dist COPY server.ts ./ # Hugging Face Spaces requires port 7860 EXPOSE 7860 # HF_TOKEN must be added as a Repository Secret in Space settings # It is read at runtime via process.env.HF_TOKEN CMD ["npm", "run", "server"]