Skip to content

Commit 1a30145

Browse files
mahataCopilot
andauthored
Update PostgreSQL configuration and add Docker Compose setup (#104)
* feat: update PostgreSQL configuration and add Docker Compose setup * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 58f286a commit 1a30145

7 files changed

Lines changed: 36 additions & 11 deletions

File tree

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SESSION_SECRET=your-super-secret-key-change-in-production
66

77
# Database Configuration
88
POSTGRES_HOST=localhost
9-
POSTGRES_PORT=5432
9+
POSTGRES_PORT=5437
1010
POSTGRES_USER=postgres
1111
POSTGRES_PASSWORD=mysecretpassword
1212
POSTGRES_DB=postgres

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,26 @@ If no `.env` file exists, the application will use system environment variables
5555

5656
### Database Setup
5757

58-
#### Option 1: Using Docker (Recommended for Development)
58+
#### Option 1: Using Docker Compose (Recommended for Development)
5959

60-
Start a PostgreSQL container:
60+
Start a PostgreSQL container using Docker Compose:
6161

6262
```bash
63-
docker run --name mlack-postgres \
64-
-e POSTGRES_PASSWORD=mysecretpassword \
65-
-p 5432:5432 \
66-
--rm postgres:17.5-bullseye
63+
docker compose up -d
64+
```
65+
66+
When started via Docker Compose, PostgreSQL is exposed on the host as `localhost:5437`. Configure your database client (or set `POSTGRES_PORT=5437` in your environment) to connect using that port instead of the default `5432`.
67+
68+
Stop the container:
69+
70+
```bash
71+
docker compose down
72+
```
73+
74+
To stop and delete all data:
75+
76+
```bash
77+
docker compose down -v
6778
```
6879

6980
#### Option 2: Using Local PostgreSQL

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
postgres:
3+
image: postgres:18.3-bookworm
4+
environment:
5+
POSTGRES_PASSWORD: mysecretpassword
6+
ports:
7+
- "5437:5432"
8+
volumes:
9+
- pgdata:/var/lib/postgresql/data
10+
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
11+
12+
volumes:
13+
pgdata:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE DATABASE test;

drizzle.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
dialect: "postgresql",
77
dbCredentials: {
88
host: process.env.POSTGRES_HOST || "localhost",
9-
port: Number(process.env.POSTGRES_PORT) || 5432,
9+
port: Number(process.env.POSTGRES_PORT) || 5437,
1010
user: process.env.POSTGRES_USER || "postgres",
1111
password: process.env.POSTGRES_PASSWORD || "mysecretpassword",
1212
database: process.env.POSTGRES_DB || "postgres",

hono/db/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as schema from "./schema.js";
55
// Create PostgreSQL connection pool
66
const pool = new Pool({
77
host: process.env.POSTGRES_HOST || "localhost",
8-
port: Number(process.env.POSTGRES_PORT) || 5432,
8+
port: Number(process.env.POSTGRES_PORT) || 5437,
99
user: process.env.POSTGRES_USER || "postgres",
1010
password: process.env.POSTGRES_PASSWORD || "mysecretpassword",
1111
database: process.env.POSTGRES_DB || "postgres",
@@ -16,4 +16,4 @@ const pool = new Pool({
1616
export const db = drizzle(pool, { schema });
1717

1818
// Export schema for use in other files
19-
export * from "./schema.js";
19+
export * from "./schema.js";

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default defineConfig({
5959
E2E_GMAIL_ACCOUNT: process.env.E2E_GMAIL_ACCOUNT || "test@example.com",
6060
// Database configuration for E2E tests
6161
POSTGRES_HOST: "localhost",
62-
POSTGRES_PORT: "5432",
62+
POSTGRES_PORT: process.env.POSTGRES_PORT ?? "5437",
6363
POSTGRES_USER: "postgres",
6464
POSTGRES_PASSWORD: "mysecretpassword",
6565
POSTGRES_DB: "test",

0 commit comments

Comments
 (0)