-
Notifications
You must be signed in to change notification settings - Fork 148
Add 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?
Add 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. |
|
|
WalkthroughA 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
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 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
| 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. |
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