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

Add docker-compose to run database locally #837

Open
wants to merge 1 commit into
base: main
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
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
# should be updated accordingly.

# Database
DATABASE_URL="postgres://YOUR_POSTGRESQL_URL"
DB_HOST=localhost
DB_USER=shadcntable
DB_PASSWORD=securepassword
DB_NAME=shadcntable
DB_PORT=5432
DATABASE_URL=`postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}`
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# database
/prisma/db.sqlite
/prisma/db.sqlite-journal
docker-data

# next.js
/.next/
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ This is a shadcn table with server-side sorting, filtering, and pagination. It i
cp .env.example .env
```

4. Start the development server
4. (Optional) Run database using docker-compose.yml file

```bash
pnpm run dev
docker compose up
```

5. Push the database schema
Expand All @@ -60,6 +60,18 @@ This is a shadcn table with server-side sorting, filtering, and pagination. It i
pnpm run db:push
```

6. Seed the database

```bash
pnpm run db:seed
```

7. Start the development server

```bash
pnpm run dev
```

## Build your own Table

1. Copy the following folders and files into your project (configured with ) at the exact specific locations
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
shadcn-table:
image: postgres:16.4
restart: always
container_name: shadcn-table
ports:
- ${DB_PORT}:5432
environment:
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_USER=${DB_USER}
- POSTGRES_DB=${DB_NAME}
volumes:
- ./docker-data/db:/var/lib/postgresql/data

volumes:
postgres: