Skip to content

Commit

Permalink
fix(docker) nextjs unable to connect to db (#6119)
Browse files Browse the repository at this point in the history
* fix(docker): nextjs unable to connect to db

* fix(docker): nextjs unable to connect to db

* fix(docker): nextjs unable to connect to db

---------

Co-authored-by: Marin Joe Garcia <[email protected]>
  • Loading branch information
joewired and Marin Joe Garcia authored Dec 10, 2024
1 parent a8103e4 commit 25c257d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/nextjs-app/.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ NEXT_BUILD_ENV_SOURCEMAPS=false
# When deploying on serverless/lambdas "?connection_limit=" should be 1
# @see https://www.prisma.io/docs/concepts/components/prisma-client/deployment#recommended-connection-limit
PRISMA_DATABASE_URL=postgresql://nextjs:!ChangeMe!@localhost:5432/maindb?schema=public
# for docker use the container name for the host
#PRISMA_DATABASE_URL=postgresql://nextjs:!ChangeMe!@main-db:5432/maindb?schema=public

# See https://github.com/soluble-io/cache-interop
APP_CACHE_DSN=
Expand Down
6 changes: 6 additions & 0 deletions docker/docker-compose.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
- POSTGRES_DB=maindb
- POSTGRES_PASSWORD=!ChangeMe!
- POSTGRES_USER=nextjs
networks:
- nextjs-monorepo-example-network
volumes:
- db_data:/var/lib/postgresql/data:rw
# you may use a bind-mounted host directory instead,
Expand All @@ -20,3 +22,7 @@ services:

volumes:
db_data:

networks:
nextjs-monorepo-example-network:
driver: bridge

0 comments on commit 25c257d

Please sign in to comment.