| FROM node:22-slim AS builder | |
| WORKDIR /app | |
| # Copy package files and install dependencies | |
| COPY package*.json ./ | |
| RUN npm install | |
| # Copy application source code | |
| COPY . . | |
| # Build the Vite application | |
| RUN npm run build | |
| # Production runtime image | |
| FROM node:22-slim | |
| WORKDIR /app | |
| # Install 'serve' globally to serve static files | |
| RUN npm install -g serve | |
| # Copy built assets from builder stage | |
| COPY --from=builder /app/dist ./dist | |
| # Hugging Face Spaces runs containers as user 1000, which is the default 'node' user in this image | |
| RUN chown -R node:node /app | |
| USER node | |
| # Hugging Face Spaces expects the app to listen on port 7860 | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Start the server, routing all requests to index.html (SPA mode) | |
| CMD ["serve", "-s", "dist", "-l", "7860"] | |