feat: env-driven server config; image honors injected PORT#30
Open
JasonWildMe wants to merge 1 commit into
Open
feat: env-driven server config; image honors injected PORT#30JasonWildMe wants to merge 1 commit into
JasonWildMe wants to merge 1 commit into
Conversation
argparse defaults now come from the environment (DEVICE, HOST, PORT, WORKERS); explicit CLI flags still override, so both compose files are unaffected. Integer envs tolerate provider-injected junk (e.g. k8s service-link PORT=tcp://...) instead of crashing at import. The image CMD no longer hardcodes --host/--port: the dockerfile sets ENV PORT=6050 HOST=0.0.0.0, so image behavior is unchanged, but a platform-injected PORT (Cloud Run) now actually reaches the server instead of being silently overridden by CMD flags. Bare-metal default port stays 8888. Written test-first: tests/test_env_config.py (subprocess probes; 4 failing tests drove the change, 4 pin compat invariants). Carved out of #26; supersedes its app/main.py hunk with the port- default compatibility preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Follow-up on the provenance note: the deferred Codex 5.6 round-4 confirmation has now run — converged, no remaining findings (PORT=0/65536 fall back consistently in both app startup and the image healthcheck; valid ports accepted). Smoke |
Author
|
Smoke build + runtime verification done:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the container's runtime config env-driven so the same image runs unmodified across providers:
app/main.py: argparse defaults come fromDEVICE/HOST/PORT/WORKERS; explicit CLI flags still win. Integer envs are validated (bare ASCII digits, port range 1–65535) and fall back with a warning instead of crashing on provider-injected junk like k8s service-linkPORT=tcp://....docker/dockerfile:CMDno longer hardcodes--host/--port(which silently defeated any platform-injectedPORT, e.g. Cloud Run's); insteadENV PORT=6050 HOST=0.0.0.0preserves image behavior exactly. TheHEALTHCHECKapplies the same validation/fallback as_int_env, so server and probe can never disagree about the bound port.python3 -m app.main.Both compose files pass explicit flags and are unaffected.
Why
This is the load-bearing 'portability contract' piece of #26, carved out atomically: without the CMD change, the env-driven PORT never engages in the shipped image; with it, Cloud Run / RunPod / VM all configure the container purely via environment.
Testing
TDD:
tests/test_env_config.py— 10 subprocess probes (app.mainparses argv at import) covering env defaults, CLI-over-env precedence, malformed/whitespace/out-of-range fallbacks, and the unchanged bare default. Full suite passes (42 existing + 10 new). Healthcheck shell logic verified against6050/ empty /tcp://junk / whitespace /0/65536inputs — matches_int_envon all.Provenance
Carved out of #26. Adversarially reviewed by Codex 5.6 (gpt-5.6-terra), 3 rounds: it drove the healthcheck/server port-validation mirroring (its round-1 Major), the whitespace-exactness fix, and the port-range validation; each fix is pinned by tests. Note: the image hasn't been rebuilt in CI here — the dockerfile change wants one smoke build before merge.
🤖 Generated with Claude Code