Conversation
Updated Dockerfile and config.py to allow setting the server port using the PORT environment variable, improving compatibility with deployment platforms like Railway and Render. The default port remains 6391 if PORT is not set.
There was a problem hiding this comment.
Pull request overview
This PR makes the server port configurable via the PORT environment variable to improve compatibility with deployment platforms like Railway and Render. The changes also update the default host binding from localhost to all interfaces.
Changes:
- Modified
agentsite/config.pyto read port from PORT environment variable and changed default host from "127.0.0.1" to "0.0.0.0" - Updated
Dockerfileto use PORT environment variable in both EXPOSE and CMD directives
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| agentsite/config.py | Added PORT environment variable support for port configuration and changed default host binding to "0.0.0.0" |
| Dockerfile | Modified EXPOSE and CMD to use PORT environment variable with 6391 as fallback |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| port: int = 6391 | ||
| # Server — also respect the plain PORT env var (used by Railway, Render, etc.) | ||
| host: str = "0.0.0.0" | ||
| port: int = int(os.environ.get("PORT", 6391)) |
There was a problem hiding this comment.
The port configuration bypasses Pydantic's BaseSettings environment variable handling by using os.environ.get() directly. This creates an inconsistency where the PORT environment variable cannot be overridden by AGENTSITE_PORT (which has the configured "env_prefix"), breaking the expected behavior of Pydantic settings.
With this implementation:
- PORT will always take precedence over AGENTSITE_PORT
- The environment variable hierarchy is not consistent with other settings in the class
Consider removing the direct os.environ.get() call and instead using Pydantic's Field with validation_alias to support both PORT and AGENTSITE_PORT. This would allow Pydantic to handle both environment variables properly while maintaining the env_prefix pattern.
| RUN cd frontend && npm run build | ||
|
|
||
| EXPOSE 6391 | ||
| EXPOSE ${PORT:-6391} |
There was a problem hiding this comment.
The EXPOSE directive with variable substitution ${PORT:-6391} is evaluated at build time, not runtime. This means the exposed port will be baked into the image based on the PORT environment variable during the build, which is typically not set during Docker builds.
This likely results in EXPOSE defaulting to an empty value or causing a build error, rather than exposing port 6391 as intended. Docker's EXPOSE is primarily for documentation and does not strictly control port binding, but having the wrong value documented in the image is misleading.
Consider either:
- Using a static
EXPOSE 6391since the actual port binding is controlled at runtime via the CMD, or - Using a build argument (ARG) if you specifically need build-time port configuration.
| EXPOSE ${PORT:-6391} | |
| EXPOSE 6391 |
| # Server — also respect the plain PORT env var (used by Railway, Render, etc.) | ||
| host: str = "0.0.0.0" |
There was a problem hiding this comment.
The host has been changed from "127.0.0.1" to "0.0.0.0" in config.py, but the documentation in README.md (line 167) and .env.copy (line 11) still show the old default value of "127.0.0.1". This creates a discrepancy between the actual default and the documented default.
This is a significant change since "0.0.0.0" allows external connections while "127.0.0.1" restricts connections to localhost only. The documentation should be updated to reflect the new default value and ideally explain the security implications of this change.
| # Server — also respect the plain PORT env var (used by Railway, Render, etc.) | |
| host: str = "0.0.0.0" | |
| # Server — default to localhost; can be overridden via AGENTSITE_HOST or similar env vars. | |
| host: str = "127.0.0.1" |
Updated Dockerfile and config.py to allow setting the server port using the PORT environment variable, improving compatibility with deployment platforms like Railway and Render. The default port remains 6391 if PORT is not set.