# Stage 1: Build the Next.js application FROM node:22-slim AS builder WORKDIR /app # Copy package files and install dependencies COPY package*.json ./ RUN npm install # Copy the rest of the application code COPY . . # Build the Next.js app RUN npm run build # Stage 2: Production image FROM node:22-slim WORKDIR /app # Copy built assets from the builder stage COPY --from=builder /app/.next ./.next COPY --from=builder /app/public ./public COPY --from=builder /app/package.json . COPY --from=builder /app/next.config.js . 2>/dev/null || true # Expose port 3000 EXPOSE 3000 # Start the Next.js production server CMD ["npm", "start"]