Skip to content

feat(pg): added ability to customize postgres port when running containerized app#1173

Merged
waleedlatif1 merged 1 commit intostagingfrom
fix/dock
Aug 29, 2025
Merged

feat(pg): added ability to customize postgres port when running containerized app#1173
waleedlatif1 merged 1 commit intostagingfrom
fix/dock

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

added ability to customize postgres port when running containerized app by specifying POSTGRES_PORT, defaults to 5432

Type of Change

  • New feature

Testing

Tested manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs Building Building Preview Comment Aug 29, 2025 0:16am
sim Building Building Preview Comment Aug 29, 2025 0:16am

@waleedlatif1 waleedlatif1 merged commit bb5f40a into staging Aug 29, 2025
2 of 4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/dock branch August 29, 2025 00:16
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds the ability to customize the PostgreSQL port for containerized deployments by introducing a POSTGRES_PORT environment variable that defaults to 5432. The change affects five Docker Compose configuration files and the environment example file:

  • Environment Configuration: Added POSTGRES_PORT to .env.example with proper documentation as an optional variable
  • Docker Compose Files: Updated docker-compose.local.yml, docker-compose.prod.yml, docker-compose.ollama.yml, and .devcontainer/docker-compose.yml to use ${POSTGRES_PORT:-5432} in both database connection URLs and port mappings
  • Service Integration: Modified DATABASE_URL strings across all services (simstudio, realtime, migrations) to incorporate the configurable port

The implementation uses Docker Compose parameter expansion syntax to maintain backward compatibility while enabling port customization. This feature addresses common deployment scenarios where port 5432 might conflict with existing PostgreSQL installations or other services. The change follows established patterns in the codebase for environment variable configuration and maintains consistency across different deployment environments (development, production, local, ollama).

Confidence score: 1/5

  • This PR has a critical bug in the devcontainer configuration that will cause database connection failures when custom ports are used
  • Score reflects a fundamental error in DATABASE_URL construction where the port variable is used in the hostname position instead of the port position
  • Pay close attention to .devcontainer/docker-compose.yml - the DATABASE_URL format is incorrect and needs immediate fixing before merge

5 files reviewed, 3 comments

Edit Code Review Bot Settings | Greptile

Comment on lines +12 to +13
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
- POSTGRES_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Critical error: ${POSTGRES_PORT:-5432} is placed in the hostname position instead of port position. Should be postgresql://postgres:postgres@db:5432/simstudio since the container always uses internal port 5432

Suggested change
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
- POSTGRES_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio

environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Same issue here - POSTGRES_PORT variable is incorrectly used in hostname position instead of port

Suggested change
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio

dockerfile: docker/db.Dockerfile
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: POSTGRES_PORT variable incorrectly positioned in database URL - will break migrations when custom port is used

Suggested change
- DATABASE_URL=postgresql://postgres:postgres@db:${POSTGRES_PORT:-5432}/simstudio
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio

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.

1 participant