Fix entrypoint.sh arg handling - stdio mode unreachable#11
Fix entrypoint.sh arg handling - stdio mode unreachable#11elasticdotventures merged 2 commits intomainfrom
Conversation
Co-authored-by: elasticdotventures <35611074+elasticdotventures@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes Docker image startup so that explicitly provided container arguments (e.g., stdio) are honored instead of being overridden by the default env-based mode selection.
Changes:
- Prioritizes explicit command-line args (
$# > 0) sodocker run … stdioworks. - Removes the earlier MODE-based
execblock that made subsequent logic unreachable. - Uses
CRATEDOCS_MODEonly as a fallback when no args are provided, with acasefor supported modes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # If explicit args provided, run with those | ||
| if [ "$#" -gt 0 ]; then | ||
| exec /usr/local/bin/cratedocs "$@" |
There was a problem hiding this comment.
With the new "explicit args" branch, running the container as docker run … <image> http will now execute cratedocs http directly and bypass the entrypoint’s container-specific defaults (CRATEDOCS_ADDRESS and CRATEDOCS_DEBUG). Since the CLI default for http --address is 127.0.0.1:8080, this can make the server bind localhost inside the container and appear unreachable from the host. Consider special-casing the http subcommand to inject --address "$ADDRESS" (and --debug when CRATEDOCS_DEBUG=true) unless the user already supplied those flags, or otherwise make the expected invocation explicit (must pass full args including --address 0.0.0.0:…).
Docker container ignored the
stdiocommand argument, always defaulting to HTTP mode regardless of explicit arguments passed.Issue
The entrypoint script evaluated
$MODE(defaulting to "http") before checking command-line arguments. Since the first conditional usedexec, it terminated immediately, making lines 17-38 unreachable dead code.Changes
$#) to execute firstCRATEDOCS_MODE) now only applies when no args providedBoth invocation patterns now work:
docker run ... stdio→ uses command argdocker run -e CRATEDOCS_MODE=stdio ...→ uses env vardocker run ...→ defaults to HTTP💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.