Skip to content

Instantly share code, notes, and snippets.

@arunavo4
Created September 16, 2024 04:26
Show Gist options
  • Save arunavo4/ec881e5166dfbfe4045777dcb732a83e to your computer and use it in GitHub Desktop.
Save arunavo4/ec881e5166dfbfe4045777dcb732a83e to your computer and use it in GitHub Desktop.
Reduce Next.js Docker Image Size
FROM node:20-alpine AS deps
COPY package*.json ./
RUN npm ci
FROM node:20-alpine AS builder
COPY . .
COPY --from=deps /node_modules ./node_modules
RUN npm run build
FROM node:20-alpine AS runner
COPY --from=builder /.next/standalone ./
# COPY --from=builder /public ./public
# COPY --from=builder /.next/static ./.next/static
EXPOSE 3000
ENV PORT 3000
CMD HOSTNAME="0.0.0.0" node server.js
module.exports = {
output: 'standalone',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment