Skip to content

Commit c326edb

Browse files
committed
docs: update contributing guide with Docker setup instructions
feat: add docker-compose file for PostgreSQL and Adminer services
1 parent 8a11abb commit c326edb

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

CONTRIBUTING.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,48 @@ BASE_URL="http://localhost:3000/api"
9494

9595
Composter uses Prisma ORM with PostgreSQL and Better Auth for authentication tables. **Important:** follow the migration order below to avoid schema conflicts.
9696

97-
1. Set up your database (local Postgres or hosted DB like Neon).
98-
2. Update `apps/api/.env` with `DATABASE_URL`.
99-
3. Run Prisma migrations from `apps/api`:
97+
#### Step 1: Start the database with Docker Compose
98+
99+
From the repository root, run:
100+
101+
```bash
102+
docker compose up -d
103+
```
104+
105+
This starts:
106+
- **PostgreSQL** on port `5432` (configurable via `DB_PORT` env var)
107+
- **Adminer** (database UI) on [http://localhost:8080](http://localhost:8080)
108+
109+
**Default credentials:**
110+
| Variable | Default Value |
111+
|----------|---------------|
112+
| `DB_USER` | `composter` |
113+
| `DB_PASSWORD` | `composter` |
114+
| `DB_NAME` | `composter_db` |
115+
| `DB_PORT` | `5432` |
116+
117+
To customize, set environment variables before running `docker compose up`:
118+
119+
```bash
120+
DB_PORT=5433 DB_PASSWORD=mysecret docker compose up -d
121+
```
122+
123+
#### Step 2: Configure DATABASE_URL
124+
125+
Update `apps/api/.env` with the connection string matching your Docker setup:
126+
127+
```env
128+
DATABASE_URL="postgresql://composter:composter@localhost:5432/composter_db"
129+
```
130+
131+
#### Step 3: Run Prisma migrations
100132

101133
```bash
102134
cd apps/api
103135
npx prisma migrate dev
104136
```
105137

106-
4. Run Better Auth migrations (if required by your setup):
138+
#### Step 4: Run Better Auth migrations
107139

108140
```bash
109141
npx @better-auth/cli migrate

docker-compose.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
services:
3+
adminer:
4+
image: adminer
5+
restart: always
6+
ports:
7+
- "8080:8080"
8+
postgres:
9+
image: postgres:17
10+
container_name: composter-db
11+
restart: always
12+
13+
14+
ports:
15+
- "${DB_PORT:-5432}:5432"
16+
environment:
17+
POSTGRES_USER: "${DB_USER:-composter}"
18+
POSTGRES_PASSWORD: "${DB_PASSWORD:-composter}"
19+
POSTGRES_DB: "${DB_NAME:-composter_db}"
20+
21+
volumes:
22+
- db_data:/var/lib/postgresql/data
23+
24+
volumes:
25+
db_data:

0 commit comments

Comments
 (0)