Dockerize a Next.js app using multi-stage builds

See the source code for a working example. Next.js is a popular React Framework that comes with a lot of great features such as hybrid static & server rendering, smart bundling, file system routing, and much more. I prefer it over vanilla React. When we dockerize a Next.js application, we want the final production and development images to be small, fast to build and easy to maintain. Let’s see how we can use multi-stage builds and other image optimization techniques to create the ideal images. ...

February 26, 2022 · 4 min · Johnny Metz