# Base image FROM node:22-alpine AS builder ARG NODE_ENV=production ARG MONGODB_URI ARG MONGODB_DB # Create app directory WORKDIR /app # Install dependencies COPY package.json ./ RUN apk add --no-cache libc6-compat RUN rm -rf node_modules package-lock.json yarn.lock pnpm-lock.yaml RUN npm install --omit=dev # Copy the rest of the application COPY . . # Build the app RUN npm run build # Production image FROM node:22-alpine AS runner WORKDIR /app # Copy only necessary files COPY --from=builder /app/package.json ./ COPY --from=builder /app/.next .next COPY --from=builder /app/public ./public COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/next.config.ts ./ # Set environment variables (optional) # Expose port EXPOSE 3000 # Start the application CMD ["npm", "start"]