Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(nextjs): Add dev db setup #632

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions next/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_PRISMA_URL=postgresql://postgres:postgres@localhost:5433/myapp
POSTGRES_URL_NON_POOLING=postgresql://postgres:postgres@localhost:5433/myapp
NEXT_PUBLIC_DSN=...
3 changes: 3 additions & 0 deletions next/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.vercel
.env

migrations
32 changes: 30 additions & 2 deletions next/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
## About
## Local Development

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
### Database Setup

1. Start the PostgreSQL database using Docker Compose:

```bash
docker compose up -d
```

2. Create a `.env` file in the root directory using `.env.example` as a template:

e.g.

```bash
POSTGRES_PRISMA_URL=postgresql://postgres:postgres@localhost:5433/myapp
POSTGRES_URL_NON_POOLING=postgresql://postgres:postgres@localhost:5433/myapp
NEXT_PUBLIC_DSN=...
```

3. Initialize the database schema:

```bash
npx prisma migrate dev --name init
```

4. Seed the database with initial data:

```bash
npx prisma db seed
```

## Deploy

Expand Down
16 changes: 16 additions & 0 deletions next/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
db:
image: postgres:15
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=myapp
ports:
- '5433:5432'
volumes:
- db:/var/lib/postgresql/data

volumes:
db:
driver: local
146 changes: 145 additions & 1 deletion next/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/react": "~11.1.0",
"@testing-library/user-event": "~12.1.10",
"@vercel/postgres": "^0.10.0",
"dompurify": "^3.1.7",
"history": "~5.3.0",
"next": "^15.0.1",
"prisma": "^5.21.1",
Expand All @@ -22,8 +23,7 @@
"react-scripts": "~5.0.1",
"redux": "~4.1.0",
"redux-logger": "~3.0.6",
"web-vitals": "~1.0.1",
"dompurify": "^3.1.7"
"web-vitals": "~1.0.1"
},
"scripts": {
"dev": "next dev",
Expand Down Expand Up @@ -76,10 +76,14 @@
"npm": "^10.8.2",
"prettier": "^3.3.3",
"react-app-rewired": "~2.2.1",
"redux-mock-store": "^1.5.4"
"redux-mock-store": "^1.5.4",
"ts-node": "^10.9.2"
},
"volta": {
"node": "18.19.1",
"npm": "10.5.0"
},
"prisma": {
"seed": "ts-node seed.ts"
}
}
}
Loading