Skip to content

feat(docker): make API port configurable via PORT environment variable#711

Open
soyr-redhat wants to merge 2 commits into
plastic-labs:mainfrom
soyr-redhat:feat/configurable-docker-port
Open

feat(docker): make API port configurable via PORT environment variable#711
soyr-redhat wants to merge 2 commits into
plastic-labs:mainfrom
soyr-redhat:feat/configurable-docker-port

Conversation

@soyr-redhat
Copy link
Copy Markdown

@soyr-redhat soyr-redhat commented May 21, 2026

This PR makes the Honcho API server port configurable via a PORT environment variable in the .env file, allowing users to easily avoid port conflicts with services that commonly use port 8000.

MOTIVATION

Port 8000 is commonly used by local LLM engines (Ollama, LM Studio, vLLM, etc.), making it difficult to run Honcho alongside these tools. Previously, users had to manually edit multiple files (docker-compose.yml, docker/entrypoint.sh, Dockerfile, and healthcheck configuration) to change the port. This PR simplifies the process to a single environment variable change.

CHANGES

Added PORT setting to .env.template with clear documentation (defaults to 8000)
Updated docker-compose.yml.example to use ${PORT:-8000} for port mapping
Updated docker/entrypoint.sh to accept PORT environment variable
Updated Dockerfile CMD to use PORT environment variable
Updated healthcheck to dynamically read the configured port
Updated README with instructions for customizing the port

TESTING

Verified both scenarios work correctly with Docker Compose:
Default behavior (PORT=8000):
API responds on http://localhost:8000/health

Custom port (PORT=3001):
API responds on http://localhost:3001/health

USAGE EXAMPLE

Users can now simply set the port in their .env file:
cp docker-compose.yml.example docker-compose.yml
cp .env.template .env
Edit .env and set PORT=3001 (or any desired port)
docker compose up

All services automatically use the configured port with no additional file edits required.

Closes #706

Summary by CodeRabbit

  • New Features

    • Server port is now configurable via a PORT environment variable (defaults to 8000).
  • Documentation

    • Updated Docker self-hosting quick start and examples to show setting PORT in .env and adjusting the SDK base URL if you change the port.
    • Docker Compose example now demonstrates using the PORT variable for service port mapping and health checks.

Review Change Stack

Allow users to customize the API server port via the PORT environment variable in .env, making it easier to avoid conflicts with services like Ollama, LM Studio, vLLM, or other local LLM engines that commonly use port 8000. Defaults to 8000 if not set.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8745c7cb-9785-4006-b41b-b5f88edb745e

📥 Commits

Reviewing files that changed from the base of the PR and between c74d4c8 and fc42cf9.

📒 Files selected for processing (1)
  • README.md
✅ Files skipped from review due to trivial changes (1)
  • README.md

Walkthrough

The PR makes the API port configurable via a PORT environment variable and updates .env.template, Dockerfile, docker/entrypoint.sh, docker-compose.yml.example, and README so the container port, startup command, port mapping, and healthcheck all use that variable (default 8000).

Changes

Configurable Docker API Server Port

Layer / File(s) Summary
Configuration declaration and docs
.env.template, README.md
Adds PORT to .env.template with default 8000 and inline docs; README quick-start note and SDK snippet updated to mention overriding PORT in .env.
Container runtime startup
Dockerfile, docker/entrypoint.sh
Dockerfile CMD changed to sh -c running fastapi run --port ${PORT:-8000}; docker/entrypoint.sh logs the selected port and starts FastAPI with --port "${PORT:-8000}".
Service port mapping and healthcheck
docker-compose.yml.example
api service adds PORT=${PORT:-8000} to environment, uses 127.0.0.1:${PORT:-8000}:${PORT:-8000} for ports, and constructs the healthcheck URL from ${PORT:-8000}.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A port once bound to eight-oh-oh,
Now bounces freely, high and low—
Set PORT=8080 and off we go,
Honcho hops where users show! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: making the API port configurable via a PORT environment variable.
Linked Issues check ✅ Passed All coding requirements from issue #706 are met: PORT environment variable is centralized, documented in .env.template, integrated into Dockerfile, docker-compose.yml.example, docker/entrypoint.sh, and healthcheck.
Out of Scope Changes check ✅ Passed All changes are within scope: configuration files, Docker setup, documentation, and entrypoint script modifications directly address making the port configurable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 287-288: The README's SDK base URL example still hardcodes
"localhost:8000" after instructing users to change PORT in their .env; update
the example to use the configurable port (e.g., show "http://localhost:${PORT}"
or use a placeholder like "http://localhost:<PORT>" or explicitly reference
process.env.PORT) so the sample call respects the PORT value set in .env and
avoids failed requests when users choose a different port (replace the hardcoded
"localhost:8000" example with the dynamic/placeholder form).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a881eff-c887-4d61-872a-4796b36d2ff1

📥 Commits

Reviewing files that changed from the base of the PR and between b5f24a6 and c74d4c8.

📒 Files selected for processing (5)
  • .env.template
  • Dockerfile
  • README.md
  • docker-compose.yml.example
  • docker/entrypoint.sh

Comment thread README.md
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.

Changing the docker port from 8000

1 participant