Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Update docker image to leverage output traces (vercel#32258)
Browse files Browse the repository at this point in the history
This updates our docker example to leverage the output traces and standalone build to reduce the resulting docker image quite a bit. 

docker image size before: `272MB`
docker image size after: `121MB`
node-14:alpine size (base image): `118MB`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`

x-ref: vercel#32255
x-ref: vercel#32252
x-ref: vercel#30822
  • Loading branch information
ijjk authored and cdierkens committed Dec 20, 2021
1 parent dd3f08d commit cb846d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/with-docker/Dockerfile
Expand Up @@ -25,10 +25,13 @@ RUN adduser -S nextjs -u 1001
# You only need to copy next.config.js if you are NOT using the default configuration
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000
Expand All @@ -40,4 +43,4 @@ ENV PORT 3000
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1

CMD ["node_modules/.bin/next", "start"]
CMD ["node", "server.js"]
5 changes: 5 additions & 0 deletions examples/with-docker/next.config.js
@@ -0,0 +1,5 @@
module.exports = {
experimental: {
outputStandalone: true,
},
}

0 comments on commit cb846d6

Please sign in to comment.