Next.js (Multi-Stage) The Next.js Dockerfile uses three stages: install dependencies, build the app, and create a minimal runtime image using the standalone output. Database Migrator (Run-Once) The migrator is a short-lived container that runs database migrations and exits. It uses restartPolicy: Never in Kubernetes or restart: "no" in Compose.