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

  • Chores
    • Added PostgreSQL database container configuration for deployment

@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

A new PostgreSQL 18.0 Alpine-based Dockerfile is added to the repository. It configures database credentials (opensox user and database) as environment variables and exposes port 5432 for database access.

Changes

Cohort / File(s) Summary
PostgreSQL Dockerfile
postgres.Dockerfile
New Dockerfile for PostgreSQL 18.0 Alpine image with environment variables (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB set to opensox) and port 5432 exposure

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A Docker for postgres, so fine and so bright,
With Alpine so lean, configured just right,
Port 5432 awaits, where data will flow,
opensox credentials in place—ready to go! 🗄️

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 title 'Add posgreSQL for local development' directly corresponds to the main change: introducing a postgres.Dockerfile for local development purposes.
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.

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