fix(pg): fix POSTGRES_PORT envvar to map external port to 5432 internally#1187
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a critical Docker networking configuration issue across all docker-compose files in the SimStudio application. The change standardizes PostgreSQL port handling by hardcoding the internal database port to 5432 in all DATABASE_URL connection strings while preserving the ability to customize external port mapping through the POSTGRES_PORT environment variable.
Previously, the configuration incorrectly used ${POSTGRES_PORT:-5432} for both external port mapping AND internal connection URLs. This created a problematic scenario: when users set POSTGRES_PORT to a custom value (e.g., 5555 to avoid port conflicts), the internal services would attempt to connect to db:5555, but PostgreSQL always runs on port 5432 inside its container. The external port mapping '${POSTGRES_PORT:-5432}:5432' was correctly configured, but the connection strings weren't aligned with this pattern.
The fix affects four docker-compose files:
docker-compose.local.yml- Local development environmentdocker-compose.prod.yml- Production environment.devcontainer/docker-compose.yml- Development container setupdocker-compose.ollama.yml- Ollama integration setup
In each file, the simstudio, realtime, and migrations services now use hardcoded port 5432 in their DATABASE_URL connection strings, while the db service maintains the flexible external port mapping. This change implements proper Docker networking best practices where internal service-to-service communication uses standard ports, and only host-to-container access requires custom port mapping.
Confidence score: 5/5
- This PR is safe to merge with minimal risk
- Score reflects a straightforward configuration fix that aligns with Docker networking best practices and resolves a clear connectivity bug
- No files require special attention as the changes are consistent and well-understood networking fixes
4 files reviewed, no comments
Summary
fix POSTGRES_PORT envvar to map external port to 5432 internally, previously we had a mix of using the postgres port directly but we should map the users external port to 5432 interally, since that follows best practices for networking with docker
Type of Change
Testing
Tested manually by connecting to port 5555 and 5433
Checklist