Skip to content

Conversation

@SanthoshKumar1903
Copy link

@SanthoshKumar1903 SanthoshKumar1903 commented Nov 13, 2025

Summary

Added PostgreSQL Docker container setup for local development, and documented why we don't use Docker for the application itself.

What's changed

  • Added postgres.Dockerfile for PostgreSQL-only container
  • Provides clear instructions for local development setup
  • Explains pnpm + monorepo + Docker limitations

Why

After extensive testing, I found that:

  1. Multi-stage Docker builds fail due to pnpm workspace symlinks
  2. API Docker build requires DATABASE_URL at build time (not available)
  3. The best approach: PostgreSQL in Docker, development locally with pnpm

How to use

  1. Build: docker build -f postgres.Dockerfile -t opensox-db .
  2. Run: docker run -p 5432:5432 --name opensox-postgres opensox-db
  3. Test: psql -h localhost -U opensox -d opensox -c "SELECT NOW();" Requires: psql in local

Next steps

After this PR, Add documentation to README explaining this setup for local development.

Summary by CodeRabbit

  • Documentation

    • Simplified setup to a database-focused Docker workflow and updated local setup steps.
    • Added an environment configuration template with default PostgreSQL credentials and usage guidance.
  • Chores

    • Added a development Docker Compose configuration for PostgreSQL with health checks and persistent storage.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 13, 2025

@SanthoshKumar1903 is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel.

A member of the Team first needs to authorize it.

@cla-assistant
Copy link

cla-assistant bot commented Nov 13, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Added a DB-focused development setup: a new .env.example with PostgreSQL credentials, a docker-compose.dev.yml providing a Postgres service with volume and healthcheck, and updated README.md instructions to use the new env file and compose command. (28 words)

Changes

Cohort / File(s) Change Summary
Environment template
.env.example
Added a template containing POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB with comments instructing users to copy it to .env, start services with docker-compose.dev.yml, and align frontend/backend credentials.
Docker Compose (dev)
docker-compose.dev.yml
Added a DB-only compose file defining a postgres service using image postgres:18, env_file: .env, port mapping 5432:5432, named volume opensox_postgres_data mounted at /var/lib/postgresql, a pg_isready healthcheck, and declared the volume.
Documentation
README.md
Replaced the prior multi-service Docker example with DB-only instructions: copy .env.example to .env and run docker-compose -f docker-compose.dev.yml up -d; removed the previous docker-compose.yml example and its multi-service blocks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify .env.example contains placeholder values (no real secrets).
  • Confirm docker-compose.dev.yml uses intended image tag postgres:18 and correct data directory /var/lib/postgresql.
  • Check healthcheck: pg_isready -U ${POSTGRES_USER} and that env_file interpolation works as expected.
  • Ensure README examples reference the exact filenames and commands.

Poem

🐰 I found a .env in the glade,
a Postgres burrow softly laid,
volumes stacked like carrot rows,
compose up — the little database grows,
I nibble logs and hop away 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main changes: it adds docker-compose.dev.yml for PostgreSQL local development setup, which aligns with the primary objectives and file changes (docker-compose.dev.yml, .env.example, and README.md updates).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
postgres.Dockerfile (1)

1-7: Add volume persistence and health check for better development experience.

While the Dockerfile is functional, consider these optional enhancements:

  1. Volume persistence: Add a volume mount to persist data across container restarts (included in docker-compose example above).
  2. Health check: Add a HEALTHCHECK to allow Docker and dev tools to verify database readiness:
HEALTHCHECK --interval=10s --timeout=5s --retries=5 \
  CMD pg_isready -U opensox -d opensox

The docker-compose approach in the previous comment addresses both concerns while keeping the Dockerfile minimal.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5445fd9 and a73b524.

📒 Files selected for processing (1)
  • postgres.Dockerfile (1 hunks)
🔇 Additional comments (1)
postgres.Dockerfile (1)

1-1: Verify PostgreSQL 18.0 support with Prisma 5.22.0 before deployment.

The application uses Prisma ORM 5.22.0, which does not explicitly list PostgreSQL 18.0 support in its release documentation. PostgreSQL 18 is very recent (released September 25, 2025) and was likely released after Prisma 5.22.0 was built. While the migration SQL uses standard PostgreSQL syntax that should be compatible, untested combinations can introduce unexpected issues.

Before deploying to production:

  • Test the application thoroughly with PostgreSQL 18.0 to confirm all database operations work correctly
  • Consider upgrading Prisma to the latest stable version that explicitly documents PostgreSQL 18 support, or verify your current version through Prisma's official compatibility matrix

Comment on lines 3 to 5
ENV POSTGRES_USER=opensox
ENV POSTGRES_PASSWORD=opensox
ENV POSTGRES_DB=opensox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Move hardcoded credentials to runtime environment variables.

Hardcoding credentials in the Dockerfile embeds them permanently in the image layer history. This is a security risk, especially if the image is ever pushed to a registry. Credentials should be passed at container runtime instead.

Use docker run with the -e flag to pass credentials at runtime:

docker run -p 5432:5432 \
  -e POSTGRES_USER=opensox \
  -e POSTGRES_PASSWORD=opensox \
  -e POSTGRES_DB=opensox \
  --name opensox-postgres opensox-db

Alternatively, use a docker-compose.yml to manage credentials via an .env file:

version: '3.8'
services:
  postgres:
    build:
      dockerfile: postgres.Dockerfile
    container_name: opensox-postgres
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-opensox}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-opensox}
      POSTGRES_DB: ${POSTGRES_DB:-opensox}
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Then create a .env file (and add it to .gitignore):

POSTGRES_USER=opensox
POSTGRES_PASSWORD=opensox
POSTGRES_DB=opensox

Then run with: docker-compose up -d

🤖 Prompt for AI Agents
postgres.Dockerfile lines 3-5: the file currently hardcodes
POSTGRES_USER/POSTGRES_PASSWORD/POSTGRES_DB which embeds secrets in the image
history; remove these ENV lines from the Dockerfile and rely on passing these
values at container runtime (docker run -e or via docker-compose with an .env
file), optionally expose non-secret build-time ARGs if you want defaults but do
not set actual credentials in the image, update the repo README with the
recommended docker run/docker-compose invocation, and add instructions to create
an .env and ensure .env is listed in .gitignore.

@huamanraj
Copy link
Collaborator

@SanthoshKumar1903 make changes according to coderabbit reviews

@SanthoshKumar1903
Copy link
Author

Ok bro, I am working on separate docker files for frontend and backend. And docker compose file for local development.

@SanthoshKumar1903 SanthoshKumar1903 changed the title Add posgreSQL for local development fear: Added docker-compose.dev.yml for posgreSQL for local development Dec 8, 2025
@SanthoshKumar1903 SanthoshKumar1903 changed the title fear: Added docker-compose.dev.yml for posgreSQL for local development feat: Added docker-compose.dev.yml for posgreSQL for local development Dec 8, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 680bbc7 and a5ba554.

📒 Files selected for processing (3)
  • .env.example (1 hunks)
  • README.md (1 hunks)
  • docker-compose.dev.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: apsinghdev/opensox PR: 0
File: apps/api/.cursor/rules/backend_rules.mdc:0-0
Timestamp: 2025-11-25T07:34:58.984Z
Learning: Document all required environment variables in `.env.example`
📚 Learning: 2025-11-25T07:34:58.984Z
Learnt from: CR
Repo: apsinghdev/opensox PR: 0
File: apps/api/.cursor/rules/backend_rules.mdc:0-0
Timestamp: 2025-11-25T07:34:58.984Z
Learning: Document all required environment variables in `.env.example`

Applied to files:

  • .env.example
🪛 dotenv-linter (4.0.0)
.env.example

[warning] 6-6: [UnorderedKey] The POSTGRES_PASSWORD key should go before the POSTGRES_USER key

(UnorderedKey)


[warning] 7-7: [EndingBlankLine] No blank line at the end of the file

(EndingBlankLine)


[warning] 7-7: [UnorderedKey] The POSTGRES_DB key should go before the POSTGRES_PASSWORD key

(UnorderedKey)

🪛 LanguageTool
README.md

[grammar] ~232-~232: Ensure spelling is correct
Context: ...ostgreSQL, cp .env.example .env in root directry with required variables, then run docke...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

Comment on lines 230 to 240
### Using Docker Compose for Database (Only)

Then run:
For a DB setup with PostgreSQL, cp .env.example .env in root directry with required variables, then run docker-compose.dev.yml

```bash
docker-compose up -d
cp .env.example .env
```
Then run,
```bash
docker-compose -f docker-compose.dev.yml up -d
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo and improve sentence clarity in Docker Compose section.

Line 232 has a typo ("directry" → "directory") and the phrasing mixes explanation with a bash command awkwardly.

Apply this diff to improve clarity:

 ### Using Docker Compose for Database (Only)
 
-For a DB setup with PostgreSQL, cp .env.example .env in root directry with required variables, then run docker-compose.dev.yml
+For a DB setup with PostgreSQL, copy `.env.example` to `.env` in the root directory with required variables, then run the compose file:
 
 ```bash
 cp .env.example .env
🧰 Tools
🪛 LanguageTool

[grammar] ~232-~232: Ensure spelling is correct
Context: ...ostgreSQL, cp .env.example .env in root directry with required variables, then run docke...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In README.md around lines 230 to 240, fix the typo "directry" → "directory" and
rephrase the sentence for clarity by separating the explanation from the
commands: state that for a PostgreSQL DB setup you should copy .env.example to
.env in the project root and set required variables, then run the docker-compose
file; place the shell commands on their own properly formatted bash code blocks
(one for the cp command and one for the docker-compose up command) so the
instructions are clear and not mixed into the explanatory sentence.

SanthoshKumar1903 and others added 3 commits December 8, 2025 13:36
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
README.md (1)

230-240: Refine the Docker Compose instructions for clarity—previous suggestions not fully addressed.

The typo fix ("directory") is appreciated, but the phrasing on line 232 still mixes command syntax into the explanation sentence, and line 237's "Then run," is incomplete. The steps should be separated more clearly: explain the intent, then show commands in separate code blocks.

Apply this diff to improve readability:

 ### Using Docker Compose for Database (Only)

-For a DB setup with PostgreSQL, cp .env.example .env in root directory with required variables, then run docker-compose.dev.yml
+For a DB setup with PostgreSQL, copy `.env.example` to `.env` in the root directory and update the required variables, then run the compose file:

 ```bash
 cp .env.example .env
-```
-Then run,
+```
+
 ```bash
 docker-compose -f docker-compose.dev.yml up -d

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: CodeRabbit UI

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between dc5e3d78c13827db91c0ff56f9261acce35afd1a and fca17c2e1590b6960cfcceb1d46d25ad775dfdeb.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `README.md` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (1)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: CR
Repo: apsinghdev/opensox PR: 0
File: apps/api/.cursor/rules/backend_rules.mdc:0-0
Timestamp: 2025-11-25T07:34:58.984Z
Learning: Document all required environment variables in .env.example


</details>

</details>

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@SanthoshKumar1903
Copy link
Author

SanthoshKumar1903 commented Dec 8, 2025

@ajeetunc @apsinghdev Can you please review my PR. I have added docker-compose.dev.yml for db setup in docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants