-
Notifications
You must be signed in to change notification settings - Fork 159
feat: Added docker-compose.dev.yml for posgreSQL for local development #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Added docker-compose.dev.yml for posgreSQL for local development #154
Conversation
|
@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. |
|
|
WalkthroughAdded a DB-focused development setup: a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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:
- Volume persistence: Add a volume mount to persist data across container restarts (included in docker-compose example above).
- Health check: Add a
HEALTHCHECKto allow Docker and dev tools to verify database readiness:HEALTHCHECK --interval=10s --timeout=5s --retries=5 \ CMD pg_isready -U opensox -d opensoxThe 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
📒 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
postgres.Dockerfile
Outdated
| ENV POSTGRES_USER=opensox | ||
| ENV POSTGRES_PASSWORD=opensox | ||
| ENV POSTGRES_DB=opensox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-dbAlternatively, 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=opensoxThen 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.
|
@SanthoshKumar1903 make changes according to coderabbit reviews |
|
Ok bro, I am working on separate docker files for frontend and backend. And docker compose file for local development. |
a73b524 to
680bbc7
Compare
680bbc7 to
a5ba554
Compare
There was a problem hiding this 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
📒 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)
| ### 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 | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this 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 -->
|
@ajeetunc @apsinghdev Can you please review my PR. I have added docker-compose.dev.yml for db setup in docker. |
Summary
Added PostgreSQL Docker container setup for local development, and documented why we don't use Docker for the application itself.
What's changed
postgres.Dockerfilefor PostgreSQL-only containerWhy
After extensive testing, I found that:
How to use
docker build -f postgres.Dockerfile -t opensox-db .docker run -p 5432:5432 --name opensox-postgres opensox-dbpsql -h localhost -U opensox -d opensox -c "SELECT NOW();"Requires: psql in localNext steps
After this PR, Add documentation to README explaining this setup for local development.
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.