Skip to content

Make server port configurable via PORT environment variable#6

Merged
jhd3197 merged 1 commit into
mainfrom
dev
Feb 2, 2026
Merged

Make server port configurable via PORT environment variable#6
jhd3197 merged 1 commit into
mainfrom
dev

Conversation

@jhd3197

@jhd3197 jhd3197 commented Feb 2, 2026

Copy link
Copy Markdown
Owner

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.

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.
Copilot AI review requested due to automatic review settings February 2, 2026 02:14
@jhd3197 jhd3197 merged commit c2fa372 into main Feb 2, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.py to read port from PORT environment variable and changed default host from "127.0.0.1" to "0.0.0.0"
  • Updated Dockerfile to 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.

Comment thread agentsite/config.py
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))

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread Dockerfile
RUN cd frontend && npm run build

EXPOSE 6391
EXPOSE ${PORT:-6391}

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

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

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:

  1. Using a static EXPOSE 6391 since the actual port binding is controlled at runtime via the CMD, or
  2. Using a build argument (ARG) if you specifically need build-time port configuration.
Suggested change
EXPOSE ${PORT:-6391}
EXPOSE 6391

Copilot uses AI. Check for mistakes.
Comment thread agentsite/config.py
Comment on lines +22 to +23
# Server — also respect the plain PORT env var (used by Railway, Render, etc.)
host: str = "0.0.0.0"

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested 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"

Copilot uses AI. Check for mistakes.
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