Spaces:
Runtime error
Runtime error
| # ---------- build stage ---------- | |
| FROM node:20-slim AS builder | |
| WORKDIR /app | |
| # Install deps (non-strict to avoid lockfile mismatches) | |
| COPY frontend/package*.json frontend/ | |
| COPY backend/package*.json backend/ | |
| RUN npm install --prefix frontend | |
| RUN npm install --omit=dev --prefix backend | |
| # Copy sources | |
| COPY frontend ./frontend | |
| COPY backend ./backend | |
| # Build React app | |
| RUN npm run build --prefix frontend | |
| # ---------- runtime ---------- | |
| FROM node:20-slim | |
| WORKDIR /app | |
| # Bring backend + built frontend | |
| COPY --from=builder /app/backend ./backend | |
| COPY --from=builder /app/frontend/dist ./frontend/dist | |
| ENV NODE_ENV=production | |
| # Hugging Face sets $PORT (usually 7860). We bind to it explicitly. | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Start Express (serves /api + frontend/dist) | |
| CMD ["node", "backend/src/server.js"] | |