Issue: Prisma unable to connect to the database during Docker build time
Context
- Environment: Dokku
- Database: Dokku-managed PostgreSQL instance
- Application: Next.js
Steps
- Created a PostgreSQL database using Dokku.
- Linked the database to the Next.js application using Dokku.
Error
During the Docker build process, the following error is encountered:
Can't reach database server at `dokku-postgres-xyz`:`5432`. Please make sure your database server is running at `dokku-postgres-xyz`:`5432`
This error suggests that Prisma is unable to connect to the database during the build time of the Docker container.
Attempted Solution
I tried to make the PostgreSQL database publicly accessible and connect to it by updating the Dockerfile using build arguments. This approach worked, but I don’t want to expose my PostgreSQL database publicly for security reasons.
Question
Is there a solution to resolve this issue and allow Prisma to connect to the database during the Docker build process?