I used tips from your video and actually managed to decrease image size from 2GB to 139MB. Thanks a lot! Unfortunately some dockefile steps that you specified are stale, specifically: - CMD - ENV declaration it's an easy fix and I am still very grateful for provided info 👍
I think you can make it even smaller with a `node:lts-bullseye-slim` image. It will always use LTS version, and this image feels the best as I've read.
hey bro for standalone builds you still need to add .next/static and public folder do it in the builder stage like this after the build command: $ cp -r .next/static .next/standalone/.next $ cp -r public .next/standalone then copy the standalone folder later in the last stage as you do
I am sorry but how is the person make this i do image like this just for developement but for production a 2 phase image one to build application and after that copy build and run using node
Great video! Thanks for sharing. Can I use this approach to develop nextjs web app locally? I mean are there any benefits to create docker image and run it instead of running npm run dev?
I think it is stable enough that Next.js recommends it in their documentation. You can check out these two: nextjs.org/docs/app/api-reference/next-config-js/output github.com/vercel/next.js/tree/canary/examples/with-docker
hello what a great video to wathc thanks a lot. I have just one question about the public and static folder how can we upload them to CDN or S3, like whats the configurations that should be included to nextjs to make it work?
You can check out assetPrefix option: nextjs.org/docs/app/api-reference/next-config-js/assetPrefix Basically create a structure where the prefix is your cdn link + the commit hash so that it syncs fine.
I am pretty sure that you are supposed to build the project on your pipeline before building the docker container and only copy only the build in the docker image, don't build it inside the container.
I haven't search that topic but I think it is highly dependent on what your application consists of and how many requests you are getting per second. Let me know if there are magic tricks for optimizing the ram usage as well.