#Dockerizing Nextjs

4 messages · Page 1 of 1 (latest)

worldly lynx
#

I want some thoughts on best practices when working on nextjs with docker. My stack is nextjs, postgres, and prisma as my ORM. I want to deploy to a docker container. As this is my first time containerizing an application I have some questions.

  • Should the container only be used for prod? i.e running npm run build, then npm run start
  • Alternatively, should I run my postgres in a container, and develop through my host machine connecting to it?
  • If thats not best practice, what is the best way to set up a dockerfile/compose.yml to allow for development AND production. There seems to be controversial opinions on this online, what do you guys think

I apologize if some of my information is incorrect, I am still learning about the process. But my goal is to be able to develop/hot reload/database migrations, and then deploy to a container with an optimized build whenever I like.

Thanks!

young surgeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

bronze fossil
#

Next has some docs on docker deployments, and to be honest, for all of the hate Next.js gets about being "vercel only", I found the docker deployment to be a BREEZE, and our apps run perfectly in production with no tinkering