Introduction
In this comprehensive guide, we will walk you through the process of setting up Prisma using Docker within a Next.js 13 project. By following the steps outlined below, you will create a Docker container for your database, configure your Prisma schema, and seamlessly integrate it into your Next.js application.
Folder Structure
Before we dive into the technical details, let’s take a moment to understand the folder structure you’ll have by the end of this tutorial:
.
├── prisma
│ └── generated
| └── migrations
| schema.prisma
├── src
│ ├── app
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ ├── lib
│ │ ├── db.ts
| docker-compose.yml
└── [..]
Docker configuration
Create a docker-compose.yml
file with the following content:
version: "3"
services:
db:
image: postgres:14.1-alpine
ports:
- 5433:5432
container_name: /* your container name here */
environment:
POSTGRES_USER: /* your user here */
POSTGRES_PASSWORD: /* your password here */
POSTGRES_DB: /* your db here */
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- postgres_data_container:/var/lib/postgresql/data
volumes…