PrismaP
Prisma16mo ago
29 replies
Psuedo

NextJS + Prisma + Docker | "can't reach db server"

I will supply all of my files in comments because of the character limit.

The first issue is that when I run my docker compose up, it generates the prisma client, then it runs npm build. On the build, it cannot connect to the database server (shown on the included image)

For context, I am using this as a reference: https://github.com/99lalo/nextjs-prisma-docker

docker-compose.yml
services:
  postgres:
    image: postgres:latest
    environment:
      POSTGRES_DB: $POSTGRES_DB
      POSTGRES_USER: $POSTGRES_USER
      POSTGRES_PASSWORD: $POSTGRES_PASSWORD
    ports:
      - 5432:5432
    expose:
      - 5432

  frontend:
    build: .
    restart: always
    environment:
      - NODE_ENV=production
    ports:
      - 3001:3000
    env_file: .env
    depends_on:
      - postgres
image.png
Was this page helpful?