Guest User

Untitled

a guest
Oct 2nd, 2024
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.12 KB | None | 0 0
  1. FROM node:20.10-alpine AS base
  2.  
  3. # Install dependencies only when needed
  4. FROM base AS deps
  5. # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
  6. RUN apk add --no-cache libc6-compat
  7. WORKDIR /app
  8.  
  9. # Install dependencies based on the preferred package manager
  10. COPY package.json package-lock.json* ./
  11. RUN npm install
  12.  
  13. FROM base AS dev
  14.  
  15. WORKDIR /app
  16. COPY --from=deps /app/node_modules ./node_modules
  17. COPY . .
  18.  
  19. # Uncomment this if you're using prisma, generates prisma files for linting
  20. RUN npx prisma generate
  21.  
  22. #Enables Hot Reloading Check https://github.com/vercel/next.js/issues/36774 for more information
  23. ENV CHOKIDAR_USEPOLLING=true
  24. ENV WATCHPACK_POLLING=true
  25.  
  26. # Rebuild the source code only when needed
  27. FROM base AS builder
  28. WORKDIR /app
  29. COPY --from=deps /app/node_modules ./node_modules
  30. COPY --from=deps /root/.npm /root/.npm
  31. COPY . .
  32.  
  33. ENV NEXT_TELEMETRY_DISABLED 1
  34.  
  35. # Uncomment this if you're using prisma, generates prisma files for linting
  36. RUN npx prisma generate
  37.  
  38. RUN sleep 6
  39.  
  40. RUN npm run build
  41.  
  42. # Production image, copy all the files and run next
  43. FROM base AS runner
  44. WORKDIR /app
  45.  
  46. ENV NEXT_TELEMETRY_DISABLED 1
  47.  
  48. RUN addgroup --system --gid 1001 nodejs
  49. RUN adduser --system --uid 1001 nextjs
  50.  
  51. COPY --from=builder /app/public ./public
  52.  
  53. # Set the correct permission for prerender cache
  54. RUN mkdir .next
  55. RUN chown nextjs:nodejs .next
  56.  
  57. # Automatically leverage output traces to reduce image size
  58. # https://nextjs.org/docs/advanced-features/output-file-tracing
  59. COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
  60. COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
  61.  
  62. # Uncomment this if you're using prisma, copies prisma files for linting
  63. COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
  64.  
  65. USER nextjs
  66.  
  67. EXPOSE 3000
  68.  
  69. ENV PORT 3000
  70. # set hostname to localhost
  71. ENV HOSTNAME "0.0.0.0"
  72.  
  73. # server.js is created by next build from the standalone output
  74. # https://nextjs.org/docs/pages/api-reference/next-config-js/output
  75. CMD ["npm", "run", "start:migrate:prod"]
Advertisement
Add Comment
Please, Sign In to add comment