Nextjs + Prisma/Postgres in docker wont load layout.tsx children
Answered
Bedlington Terrier posted this in #help-forum

Bedlington TerrierOP
Hi! So I have been developing a applictaion where I used Neon as a cloud postgres database for my nextjs application. But now when I'm done I would like to run the Nextjs application in a docker container and the postgres database locally in another container. But for some reason, when I spin up the images the Nextjs layout.tsx wont load the child pages of the application? I can only see the Navbar and the Footer?
I can actually recreate this exact problem in my development setup with the Neon database connection with just setting the .env variables to the postgres database incorrectly. Then I get the same behavior.
The docker setup is supposed to be a production setup and I don't know if that's causing any problems. However, I tried using postman to reach a api endpoint in my application that do a database fetch, and it actually works. So I don't know, this is very strange
Anyone with any experience working with Prisma/Postgres in docker before?
I can actually recreate this exact problem in my development setup with the Neon database connection with just setting the .env variables to the postgres database incorrectly. Then I get the same behavior.
The docker setup is supposed to be a production setup and I don't know if that's causing any problems. However, I tried using postman to reach a api endpoint in my application that do a database fetch, and it actually works. So I don't know, this is very strange
Anyone with any experience working with Prisma/Postgres in docker before?
Answered by Bedlington Terrier
Found the problem. Becuase this is a PRODUCTION build (which I'm not used to) we didn't get any debugging logs i believe. So the problem was initially that the code i produced in the application didn't handle a empty database correctly. After adding some catches and default values to handle this it worked fine.
2 Replies

Bedlington TerrierOP
After checking the files in my built docker image of the nextjs application, I can't actually see the layout.tsx or the page.tsx? My dockerfile workdir is /app, so when I open a sh terminal in the docker container I navigate to /app/src/app and list all files ls -l, I see no layout.tsx or page.tsx which should be in the root folder. Aren't they supposed to be there in the docker container?

Bedlington TerrierOP
Found the problem. Becuase this is a PRODUCTION build (which I'm not used to) we didn't get any debugging logs i believe. So the problem was initially that the code i produced in the application didn't handle a empty database correctly. After adding some catches and default values to handle this it worked fine.
Answer