diff --git a/.env.example b/.env.example index 59558dcb..bb7711b3 100644 --- a/.env.example +++ b/.env.example @@ -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}` diff --git a/.gitignore b/.gitignore index 2971a0bd..77dd3732 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # database /prisma/db.sqlite /prisma/db.sqlite-journal +docker-data # next.js /.next/ diff --git a/README.md b/README.md index d5a42a59..cdc126de 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..e3d5ec58 --- /dev/null +++ b/docker-compose.yml @@ -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: