Created
September 16, 2024 04:26
-
-
Save arunavo4/ec881e5166dfbfe4045777dcb732a83e to your computer and use it in GitHub Desktop.
Reduce Next.js Docker Image Size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
output: 'standalone', | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment