Follow the official Next.js repo docker build example and instructions to deploy with docker. Copy the Dockerfile into the root of the project and modify the next.config.js file:
// next.config.js
module.exports = {
// ... rest of the configuration.
output: 'standalone',
}You can now build the docker image and run it:
docker build -t nextjs-docker .
docker run -p 3000:3000 nextjs-dockerAlternatively, to use docker compose, refer to the docker compose repo.