Skip to content

Fix entrypoint.sh arg handling - stdio mode unreachable#11

Merged
elasticdotventures merged 2 commits intomainfrom
copilot/review-build-status-publish-actions
Feb 8, 2026
Merged

Fix entrypoint.sh arg handling - stdio mode unreachable#11
elasticdotventures merged 2 commits intomainfrom
copilot/review-build-status-publish-actions

Conversation

Copy link

Copilot AI commented Feb 8, 2026

Docker container ignored the stdio command 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 used exec, it terminated immediately, making lines 17-38 unreachable dead code.

# Before: MODE check happened first, exec'd immediately
if [ "$MODE" = "http" ]; then
    exec /usr/local/bin/cratedocs http --address "$ADDRESS" "$@"
else
    exec /usr/local/bin/cratedocs "$MODE" "$@"
fi
# This code was never reached:
if [ "$#" -gt 0 ]; then
  exec /usr/local/bin/cratedocs "$@"
fi

Changes

  • Moved explicit argument check ($#) to execute first
  • Removed duplicate MODE-based logic (9 lines)
  • Environment variable fallback (CRATEDOCS_MODE) now only applies when no args provided

Both invocation patterns now work:

  • docker run ... stdio → uses command arg
  • docker run -e CRATEDOCS_MODE=stdio ... → uses env var
  • docker run ... → defaults to HTTP

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: elasticdotventures <35611074+elasticdotventures@users.noreply.github.com>
Copilot AI changed the title [WIP] Review build status and publish CI/CD actions Fix entrypoint.sh arg handling - stdio mode unreachable Feb 8, 2026
@elasticdotventures elasticdotventures marked this pull request as ready for review February 8, 2026 23:11
Copilot AI review requested due to automatic review settings February 8, 2026 23:11
@elasticdotventures elasticdotventures merged commit 812352a into main Feb 8, 2026
6 checks passed
@elasticdotventures elasticdotventures deleted the copilot/review-build-status-publish-actions branch February 8, 2026 23:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) so docker run … stdio works.
  • Removes the earlier MODE-based exec block that made subsequent logic unreachable.
  • Uses CRATEDOCS_MODE only as a fallback when no args are provided, with a case for supported modes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 8 to 10
# If explicit args provided, run with those
if [ "$#" -gt 0 ]; then
exec /usr/local/bin/cratedocs "$@"
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

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:…).

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.

3 participants