
Next.js Dockerfile generator
Generate a production multi-stage Dockerfile for Next.js, plus .dockerignore and compose. Runs in your browser. Nothing is sent.
- Free
- No signup
- Nothing stored
One name per line. Next.js inlines these at build time, so they are ARG values.
The runtime user is the image's node user. Sharp is bundled with Next.js 15+ when the install runs in the image.
Estimate from a fresh Next.js 16 standalone image measured on node:24-slim. The app files were about 59 MB; the rest is the base image. Yours will differ. Prisma, a monorepo, and extra dependencies change the size.
Docker files
Lines do not wrap. Scroll sideways inside this area. Line numbers stay pinned.
How it works
- 01
Pick a package manager and Node version
Choose npm, pnpm, yarn, or bun, then Node 20, 22, or 24 on Alpine or Debian slim.
- 02
Toggle standalone, Prisma, and the healthcheck
Standalone is on by default. Prisma adds prisma generate. The healthcheck calls a route with node fetch, so the image does not need curl.
- 03
Copy the files and run docker build
Download the Dockerfile, ignore file, and compose file, set output standalone in next.config, then build and run on port 3000.
What the Dockerfile ships
The default file matches the measured setup in the Next.js Dockerfile guide: Node 24 on Debian slim, standalone output, a BuildKit cache mount for the install, a healthcheck that uses node fetch, and the image's node user. A fresh standalone image on that base was about 287 MB. Alpine was about 229 MB. A single-stage image was about 1.97 GB.
NEXT_PUBLIC_ values are inlined at build time, so the file passes them as build args. Server-only secrets stay runtime environment variables. The same image runs on any Docker host, including the setup in self-hosting Next.js with Coolify.