Dockerfile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Install dependencies only when needed
  2. FROM node:16-alpine AS deps
  3. # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
  4. RUN apk add --no-cache libc6-compat
  5. WORKDIR /app
  6. COPY package.json yarn.lock ./
  7. RUN yarn install --frozen-lockfile
  8. # If using npm with a `package-lock.json` comment out above and use below instead
  9. # COPY package.json package-lock.json ./
  10. # RUN npm ci
  11. # Rebuild the source code only when needed
  12. FROM node:16-alpine AS builder
  13. ARG NEXT_PUBLIC_VERCEL_ENV
  14. ARG NEXT_PUBLIC_VERCEL_URL
  15. ARG NEXT_PUBLIC_GOOGLE_ANALYTICS_ID
  16. ARG NEXT_PUBLIC_TARTEEL_VS_API_KEY
  17. ARG NEXT_PUBLIC_FS_API_KEY
  18. ARG NEXT_PUBLIC_FS_AUTH_DOMAIN
  19. ARG NEXT_PUBLIC_FS_PROJECT_ID
  20. ARG NEXT_PUBLIC_FS_STORAGE_BUCKET
  21. ARG NEXT_PUBLIC_FS_MESSAGING_SENDER_ID
  22. ARG NEXT_PUBLIC_FS_APP_ID
  23. ARG NEXT_PUBLIC_FS_MEASUREMENT_ID
  24. ENV NEXT_PUBLIC_VERCEL_ENV=$NEXT_PUBLIC_VERCEL_ENV
  25. ENV NEXT_PUBLIC_VERCEL_URL=$NEXT_PUBLIC_VERCEL_URL
  26. ENV NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=$NEXT_PUBLIC_GOOGLE_ANALYTICS_ID
  27. ENV NEXT_PUBLIC_TARTEEL_VS_API_KEY=$NEXT_PUBLIC_TARTEEL_VS_API_KEY
  28. ENV NEXT_PUBLIC_FS_API_KEY=$NEXT_PUBLIC_FS_API_KEY
  29. ENV NEXT_PUBLIC_FS_AUTH_DOMAIN=$NEXT_PUBLIC_FS_AUTH_DOMAIN
  30. ENV NEXT_PUBLIC_FS_PROJECT_ID=$NEXT_PUBLIC_FS_PROJECT_ID
  31. ENV NEXT_PUBLIC_FS_STORAGE_BUCKET=$NEXT_PUBLIC_FS_STORAGE_BUCKET
  32. ENV NEXT_PUBLIC_FS_MESSAGING_SENDER_ID=$NEXT_PUBLIC_FS_MESSAGING_SENDER_ID
  33. ENV NEXT_PUBLIC_FS_APP_ID=$NEXT_PUBLIC_FS_APP_ID
  34. ENV NEXT_PUBLIC_FS_MEASUREMENT_ID=$NEXT_PUBLIC_FS_MEASUREMENT_ID
  35. WORKDIR /app
  36. COPY --from=deps /app/node_modules ./node_modules
  37. COPY . .
  38. RUN yarn build
  39. # Production image, copy all the files and run next
  40. FROM node:16-alpine AS runner
  41. WORKDIR /app
  42. ENV NODE_ENV production
  43. RUN addgroup -g 1001 -S nodejs
  44. RUN adduser -S nextjs -u 1001
  45. # You only need to copy next.config.js if you are NOT using the default configuration
  46. # COPY --from=builder /app/next.config.js ./
  47. COPY --from=builder /app/public ./public
  48. COPY --from=builder /app/package.json ./package.json
  49. # Automatically leverage output traces to reduce image size
  50. # https://nextjs.org/docs/advanced-features/output-file-tracing
  51. COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
  52. COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
  53. USER nextjs
  54. EXPOSE 3000
  55. ENV PORT 3000
  56. # Next.js collects completely anonymous telemetry data about general usage.
  57. # Learn more here: https://nextjs.org/telemetry
  58. # Uncomment the following line in case you want to disable telemetry.
  59. ENV NEXT_TELEMETRY_DISABLED 1
  60. CMD ["node", "server.js"]