Skip to content

Commit 0b9c0bf

Browse files
committed
fix(setup): address review comments and simplify postgres startup command
Signed-off-by: yogeshk34 <khutwadyogesh34@gmail.com>
1 parent 2a43eee commit 0b9c0bf

2 files changed

Lines changed: 29 additions & 27 deletions

File tree

README.md

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The project is pinned to `pnpm@9.15.3` (see `"packageManager"` in `package.json`
2727

2828
### • Install NestJS CLI
2929
```bash
30-
pnpm add -g @nestjs/cli
30+
npm i @nestjs/cli@latest
3131
```
3232

3333
---
@@ -53,26 +53,37 @@ Start PostgreSQL via Docker. The credentials and DB name **must match** what you
5353
```bash
5454
docker run --name credebl-postgres \
5555
-p 5432:5432 \
56-
-e POSTGRES_USER=credebl \
57-
-e POSTGRES_PASSWORD=changeme \
56+
-e POSTGRES_USER=postgres \
57+
-e POSTGRES_PASSWORD=postgres \
5858
-e POSTGRES_DB=credebl \
5959
-v credebl_pgdata:/var/lib/postgresql/data \
6060
--network platform_default \
6161
-d postgres:16
6262
```
6363

64+
> ⚠️ **If you later run `docker compose up`, Docker Compose also defines a service named `credebl-postgres`.** To avoid a container name collision, stop and remove the manually started container first (`docker rm -f credebl-postgres`) before running `docker compose up`.
65+
6466
Then update your `.env` to match those credentials:
6567

6668
```env
67-
DATABASE_URL="postgresql://credebl:changeme@localhost:5432/credebl"
68-
POOL_DATABASE_URL="postgresql://credebl:changeme@localhost:5432/credebl"
69+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/credebl"
70+
POOL_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/credebl"
6971
```
7072

7173
> ⚠️ **Do not use `localhost` in `DATABASE_URL` when services run inside Docker containers.** Inside a container, `localhost` resolves to the container itself — not the host. Use your machine's LAN IP (e.g. `192.168.x.x`) or a Docker service name instead. This applies to `KEYCLOAK_DOMAIN` and `KEYCLOAK_ADMIN_URL` as well (see Step 5).
7274
7375
---
7476

75-
### Step 3 — Run Prisma Migrations (Schema Generation)
77+
### Step 3 — Install Dependencies
78+
79+
```bash
80+
# From repo root — use pnpm, not npm
81+
pnpm install
82+
```
83+
84+
---
85+
86+
### Step 4 — Run Prisma Migrations (Schema Generation)
7687

7788
> ⚠️ **Migrations must run before seeding.** If you seed first, it will fail because the tables don't exist yet.
7889
@@ -92,11 +103,11 @@ npx prisma migrate deploy --schema=./libs/prisma-service/prisma/schema.prisma
92103

93104
---
94105

95-
### Step 4 — Set Up Keycloak
106+
### Step 5 — Set Up Keycloak
96107

97108
Keycloak is required for authentication. It is **not started automatically** — you must run it separately and configure it fully before seeding.
98109

99-
#### 4a — Run the Keycloak container
110+
#### 5a — Run the Keycloak container
100111

101112
> ⚠️ **Keycloak must be on the same Docker network as the platform services** (`platform_default`), otherwise the containers cannot reach it. Include `--network platform_default` when creating the container.
102113
@@ -109,13 +120,13 @@ docker run --name credebl-keycloak \
109120
-d quay.io/keycloak/keycloak:latest start-dev
110121
```
111122

112-
#### 4b — Create a Realm
123+
#### 5b — Create a Realm
113124

114125
1. Open the Keycloak Admin Console: `http://localhost:8080`
115126
2. Log in with `admin` / `admin`
116127
3. Create a new **Realm** named exactly: `credebl-platform`
117128

118-
#### 4c — Create Client 1: `adminClient`
129+
#### 5c — Create Client 1: `adminClient`
119130

120131
This client is used by the platform seed script and user-service to authenticate platform admin users.
121132

@@ -135,7 +146,7 @@ ADMIN_KEYCLOAK_ID=adminClient
135146
ADMIN_KEYCLOAK_SECRET=<copied-secret-from-keycloak>
136147
```
137148

138-
#### 4d — Create Client 2: `credeblClient`
149+
#### 5d — Create Client 2: `credeblClient`
139150

140151
This client is the management client used for general Keycloak operations.
141152

@@ -158,7 +169,7 @@ KEYCLOAK_REALM=credebl-platform
158169
KEYCLOAK_MASTER_REALM=master
159170
```
160171

161-
#### 4e — Set Keycloak domain in `.env`
172+
#### 5e — Set Keycloak domain in `.env`
162173

163174
> ⚠️ **If platform services run in Docker containers, do NOT use `localhost` for Keycloak URLs.**
164175
> Use your machine's LAN IP address instead (e.g. `192.168.1.x`). You can find it with `ip addr show` or `hostname -I`.
@@ -175,7 +186,7 @@ KEYCLOAK_ADMIN_URL=http://192.168.x.x:8080
175186

176187
---
177188

178-
### Step 5 — Configure Remaining `.env` Values
189+
### Step 6 — Configure Remaining `.env` Values
179190

180191
Set the following before seeding:
181192

@@ -188,7 +199,7 @@ CRYPTO_PRIVATE_KEY=YourSecretPrivateKeyHere
188199
189200
---
190201

191-
### Step 6 — Seed Initial Data
202+
### Step 7 — Seed Initial Data
192203

193204
```bash
194205
# From repo root
@@ -206,7 +217,7 @@ The seed script will:
206217
207218
---
208219

209-
### Step 7 — Install NATS Message Broker
220+
### Step 8 — Install NATS Message Broker
210221

211222
NATS is used for inter-service communication.
212223

@@ -222,20 +233,11 @@ docker compose up -d
222233

223234
---
224235

225-
### Step 8 — Install Dependencies
226-
227-
```bash
228-
# From repo root — use pnpm, not npm
229-
pnpm install
230-
```
231-
232-
---
233-
234236
### Step 9 — Run CREDEBL Microservices
235237

236238
#### Configure environment variables
237239

238-
Ensure all values in `.env` are set correctly before starting services (see Steps 4–5 above).
240+
Ensure all values in `.env` are set correctly before starting services (see Steps 5–6 above).
239241

240242
#### Running the API Gateway
241243

@@ -263,7 +265,7 @@ nest start agent-service [--watch]
263265

264266
Once the API Gateway is running, Swagger UI is available at:
265267

266-
```
268+
```text
267269
http://localhost:5000/api
268270
```
269271

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
"xml-js": "^1.6.11"
132132
},
133133
"devDependencies": {
134-
"@nestjs/cli": "^11.0.23",
134+
"@nestjs/cli": "catalog:",
135135
"@nestjs/schematics": "catalog:",
136136
"@nestjs/testing": "catalog:",
137137
"@types/express": "^4.17.25",

0 commit comments

Comments
 (0)