Skip to content

Commit 6337281

Browse files
authored
feat: update docker setup (#985)
* feat: setup docker * chore: fix lint * chore: bump pnpm * chore: update css variables
1 parent 2e74146 commit 6337281

File tree

10 files changed

+173
-223
lines changed

10 files changed

+173
-223
lines changed

.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Database
2-
DATABASE_URL="postgres://YOUR_POSTGRESQL_URL"
2+
# If not using docker, set DATABASE_URL to hosted postgres url and ignore the other database variables.
3+
DATABASE_URL="postgresql://tablecn:securepassword@localhost:5432/tablecn"
34

4-
## Docker compose (optional)
5-
DB_HOST=localhost
6-
DB_USER=shadcntable
7-
DB_PASSWORD=securepassword
8-
DB_NAME=shadcntable
9-
DB_PORT=5432
5+
DATABASE_HOST="localhost"
6+
DATABASE_USER="tablecn"
7+
DATABASE_PASSWORD="securepassword"
8+
DATABASE_NAME="tablecn"
9+
DATABASE_PORT="5432"

.github/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ runs:
1010
- name: Setup pnpm
1111
uses: pnpm/action-setup@v4
1212
with:
13-
version: 10.9.0
13+
version: 10.12.4
1414

1515
- run: pnpm install
1616
shell: bash

.github/workflows/code-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup pnpm
2323
uses: pnpm/action-setup@v4
2424
with:
25-
version: 10.9.0
25+
version: 10.12.4
2626
- uses: ./.github/setup
2727

2828
- name: Check formatting
@@ -37,7 +37,7 @@ jobs:
3737
- name: Setup pnpm
3838
uses: pnpm/action-setup@v4
3939
with:
40-
version: 10.9.0
40+
version: 10.12.4
4141
- uses: ./.github/setup
4242

4343
- run: pnpm lint
@@ -51,7 +51,7 @@ jobs:
5151
- name: Setup pnpm
5252
uses: pnpm/action-setup@v4
5353
with:
54-
version: 10.9.0
54+
version: 10.12.4
5555
- uses: ./.github/setup
5656

5757
- run: pnpm typecheck

.vscode/settings.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@
99
["clsx\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
1010
["cva\\(((?:[^()]|\\([^()]*\\))*)\\)", "[\"'`]?([^\"'`]+)[\"'`]?"],
1111
["cn\\(((?:[^()]|\\([^()]*\\))*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
12-
],
13-
"markdownlint.config": {
14-
"MD033": {
15-
"allowed_elements": ["div", "a", "img", "br"]
16-
}
17-
}
12+
]
1813
}

README.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ This is a shadcn table component with server-side sorting, filtering, and pagina
44

55
[![Shadcn Table](./public/images/screenshot.png)](https://tablecn.com)
66

7-
<div align="center">
8-
<a href="https://vercel.com/oss">
9-
<img alt="Vercel OSS Program" src="https://vercel.com/oss/program-badge.svg" />
10-
</a>
11-
</div>
12-
13-
<br />
7+
[![Vercel OSS Program](https://vercel.com/oss/program-badge.svg)](https://vercel.com/oss)
148

159
## Documentation
1610

@@ -38,46 +32,78 @@ See the [documentation](https://diceui.com/docs/components/data-table) to get st
3832

3933
## Running Locally
4034

41-
1. Clone the repository
35+
### Quick Setup
36+
37+
For first-time setup, run this single command:
38+
39+
1. **Clone the repository**
4240

4341
```bash
4442
git clone https://github.com/sadmann7/shadcn-table
43+
cd shadcn-table
4544
```
4645

47-
2. Install dependencies using pnpm
46+
2. **Copy the environment variables**
4847

4948
```bash
50-
pnpm install
49+
cp .env.example .env
5150
```
5251

53-
3. Copy the `.env.example` to `.env` and update the variables.
52+
3. **Run the setup**
5453

5554
```bash
56-
cp .env.example .env
55+
pnpm ollie
5756
```
5857

59-
4. (Optional) Run database using docker-compose.yml file
58+
This will install dependencies, start the Docker PostgreSQL instance, set up the database schema, and seed it with sample data.
59+
60+
### Manual Setup
61+
62+
1. **Clone the repository**
6063

6164
```bash
62-
docker compose up
65+
git clone https://github.com/sadmann7/shadcn-table
66+
cd shadcn-table
6367
```
6468

65-
5. Push the database schema
69+
2. **Install dependencies**
6670

6771
```bash
68-
pnpm run db:push
72+
pnpm install
73+
```
74+
75+
3. **Set up environment variables**
76+
77+
```bash
78+
cp .env.example .env
6979
```
7080

71-
6. Seed the database
81+
Update the `.env` file with your database credentials.
82+
83+
4. **Choose your database approach:**
84+
85+
**Option A: Use Docker PostgreSQL**
7286

7387
```bash
74-
pnpm run db:seed
88+
# Start PostgreSQL container
89+
pnpm db:start
90+
91+
# Set up database schema and seed data
92+
pnpm db:setup
93+
94+
# Start development server
95+
pnpm dev
7596
```
7697

77-
7. Start the development server
98+
**Option B: Use existing PostgreSQL database**
7899

79100
```bash
80-
pnpm run dev
101+
# Update .env with your database URL
102+
# Then set up database schema and seed data
103+
pnpm db:setup
104+
105+
# Start development server
106+
pnpm dev
81107
```
82108

83109
## How do I deploy this?

docker-compose.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
services:
2-
shadcn-table:
2+
postgres:
33
image: postgres:17.4
44
restart: always
5-
container_name: shadcn-table
65
ports:
7-
- ${DB_PORT}:5432
6+
- ${DATABASE_PORT}:5432
87
environment:
9-
- POSTGRES_PASSWORD=${DB_PASSWORD}
10-
- POSTGRES_USER=${DB_USER}
11-
- POSTGRES_DB=${DB_NAME}
8+
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
9+
- POSTGRES_USER=${DATABASE_USER}
10+
- POSTGRES_DB=${DATABASE_NAME}
1211
volumes:
1312
- ./docker-data/db:/var/lib/postgresql/data
14-
15-
volumes:
16-
postgres:
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U ${DATABASE_USER} -d ${DATABASE_NAME}"]
15+
interval: 10s
16+
timeout: 5s
17+
retries: 5

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@
77
"clean": "rimraf --glob **/node_modules **/dist **/.next pnpm-lock.yaml **/.tsbuildinfo",
88
"build": "next build",
99
"dev": "next dev",
10+
"dev:docker": "pnpm db:start && pnpm dev",
1011
"start": "next start",
12+
"ollie": "pnpm install && pnpm run db:start && pnpm run db:setup",
1113
"lint": "biome check .",
1214
"lint:fix": "biome check . --write",
1315
"typecheck": "tsc --noEmit",
1416
"check": "pnpm lint && pnpm typecheck",
1517
"shadcn": "pnpm dlx shadcn@latest",
1618
"build:registry": "shadcn build",
19+
"db:start": "docker compose up -d",
20+
"db:stop": "docker compose down",
1721
"db:generate": "dotenv drizzle-kit generate",
1822
"db:introspect": "dotenv drizzle-kit introspect",
1923
"db:push": "dotenv drizzle-kit push",
2024
"db:migrate": "dotenv tsx src/db/migrate.ts",
2125
"db:drop-migration": "drizzle-kit drop",
2226
"db:seed": "dotenv tsx src/db/seed.ts",
27+
"db:setup": "pnpm db:push && pnpm db:seed",
28+
"db:reset": "pnpm db:stop && rimraf docker-data && pnpm db:start && sleep 10 && pnpm db:setup",
2329
"db:studio": "dotenv drizzle-kit studio"
2430
},
2531
"dependencies": {
@@ -89,5 +95,5 @@
8995
"ct3aMetadata": {
9096
"initVersion": "7.23.1"
9197
},
92-
"packageManager": "pnpm@10.9.0"
98+
"packageManager": "pnpm@10.12.4"
9399
}

0 commit comments

Comments
 (0)