# syntax=docker.io/docker/dockerfile:1 FROM node:18-alpine AS base # Install dependencies only when needed FROM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app # Install dependencies based on the preferred package manager COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ # Copy necessary files from the builder stage # Copy production dependencies COPY --from=builder /app/node_modules ./node_modules # Copy the build output (.next folder) COPY --from=builder /app/.next ./.next # Copy public assets COPY --from=builder /app/public ./public # Copy next.config.js if it exists COPY --from=builder /app/next.config.js ./next.config.js # Set the environment variable for the Next.js port (default is 3000) # Hugging Face Spaces typically exposes port 7860 for Gradio/Streamlit/etc, # but for general web apps (like Next.js via the static host option or if you set up a custom server), # it might expose port 3000 by default when detecting a standard Next.js app. # It's good practice to set this, but Spaces often handles port mapping. ENV PORT 3000 # Expose the port the application will run on EXPOSE 3000 # Disable Next.js telemetry at runtime ENV NEXT_TELEMETRY_DISABLED 1 # Command to run the production Next.js server CMD ["npm", "start"]