services / Dockerfile
vish85521's picture
Upload 18 files
6a44dcb verified
# ── Stage 1: Build ──────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependency files first for better layer caching
COPY package.json package-lock.json* ./
RUN npm ci
# Copy the rest of the source
COPY . .
# NEXT_PUBLIC_ vars must be available at build time
ARG NEXT_PUBLIC_API_URL=https://your-backend.hf.space
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN npm run build
# ── Stage 2: Runner ──────────────────────────────────────────────
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Hugging Face Spaces requires the app to listen on port 7860
ENV PORT=7860
ENV HOSTNAME=0.0.0.0
# Only copy what is needed at runtime
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 7860
CMD ["node", "server.js"]