Spaces:
Sleeping
Sleeping
| # ββ Stage 1: Install dependencies βββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM node:20-slim AS deps | |
| WORKDIR /app | |
| COPY frontend/package*.json ./ | |
| RUN npm ci | |
| # ββ Stage 2: Build Next.js βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM node:20-slim AS builder | |
| WORKDIR /app | |
| COPY --from=deps /app/node_modules ./node_modules | |
| COPY frontend/ . | |
| # Bake the backend HuggingFace Space URL at build time. | |
| # NEXT_PUBLIC_* vars are embedded into the JS bundle during `next build`, | |
| # so they must be set here β not at container start. | |
| ARG NEXT_PUBLIC_API_URL=https://trojan0x-caretrace-backend.hf.space | |
| ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL | |
| RUN npm run build | |
| # ββ Stage 3: Lean production runner βββββββββββββββββββββββββββββββββββββββββββ | |
| FROM node:20-slim AS runner | |
| WORKDIR /app | |
| ENV NODE_ENV=production | |
| # HuggingFace Spaces requires port 7860 | |
| ENV PORT=7860 | |
| ENV HOSTNAME=0.0.0.0 | |
| # Copy only the standalone output β no node_modules needed | |
| COPY --from=builder /app/.next/standalone ./ | |
| COPY --from=builder /app/.next/static ./.next/static | |
| COPY --from=builder /app/public ./public | |
| EXPOSE 7860 | |
| CMD ["node", "server.js"] | |