Skip to content

fix(docker): write the config template only when the server starts - #1767

Merged
Oaklight merged 1 commit into
masterfrom
fix/image-entrypoint-template
Nov 26, 2026
Merged

Oaklight merged 1 commit into
masterfrom
fix/image-entrypoint-template

Conversation

@Oaklight

Copy link
Copy Markdown
Owner

What and why

Part of #1704. Found while running the new surface in the Docker image on the build host (llm-rosetta-03's frozen and containerised build check). Both image entrypoints (docker/entrypoint.sh for the Python image, docker/entrypoint-binary.sh for the binary image) generated /config/config.jsonc and printed "Edit /config/config.jsonc with your API keys and restart the container." before any command, so llm-rosetta gateway --help, llm-rosetta ext list and llm-rosetta ext install acme in a fresh container wrote a template and told the operator to restart something that was not running.

The template belongs to the start of the server. Both scripts now decide with one function, starts_server: it is true for the default CMD (llm-rosetta-gateway --config ... --host ...), for an argument list that holds only options (the existing docker run IMG --port 9000 shorthand), and for an explicit serve, as llm-rosetta-gateway serve, llm-rosetta serve or llm-rosetta[-gateway] gateway serve. Option values (--config serve.jsonc) are skipped so they are not read as a verb. Every other command, init, add, ext ..., gateway usage ..., a bare llm-rosetta, a shell, runs without the template and without the message. First-run behaviour for the server is unchanged.

To make the scripts testable the config directory is a variable, CONFIG_DIR (default /config, so nothing changes in an image; the HOME fallback for an arbitrary uid is $CONFIG_DIR/home, which is /config/home by default).

Checked on the real image, built on the build host from master 185a282 plus this change: docker run IMG llm-rosetta gateway --help and ... ext list print their output with no template and no restart note; the default CMD with no /config still prints "No config.jsonc found in /config, generating template... Edit /config/config.jsonc ... restart the container."

Tests (tests/test_docker_entrypoints.py, new, 65 cases, no Docker needed): both scripts run under sh with stub executables on PATH and CONFIG_DIR in a temporary directory. 10 server-start argv forms (default CMD, option-only, --config init.jsonc as a value, serve in each spelling) write the template when there is no config and leave an existing config alone; 12 one-off argv forms (gateway --help, gateway init, gateway usage, ext list, ext install, bare llm-rosetta, llm-rosetta gateway, llm-rosetta-gateway init, --config serve.jsonc init, ext list, gateway init, a shell) print no template message and run only the command itself (no init before it); and the Python entrypoint runs init first and then the given command in order. The old scripts fail 45 of them (they also hard-code /config, so the temporary directory cannot reach them; the red is the behaviour plus that). The tests skip when docker/ is not part of the checkout (the remote test runner does not sync it). No test deleted. Package-level edges: none.

Risk tier (tick one)

  • Pure move: code moves, no logic edit (a mechanical check proves it)
  • Boundary or contract change: imports, public API, config schema, wire format
  • Runtime-behaviour change: logic that runs differently after this PR
  • Security-relevant: auth, keys, credentials, sanitizing, network exposure

Verification

  • make lint and make test pass. Result: ruff clean; the new module 65 passed locally; a full run on the remote runner (before the skip guard for a missing docker/ was added) had the 4 known remote-runner failures, the import-time-clock test_usage cases, one test_updates failure and one test_unknown_model error from OSError: [Errno 24] Too many open files on the runner, and 43 failures in the new module because docker/ is not synced there; none reproduces locally, and GitHub's CI is the gate
  • ty clean (python scripts/dev/run_ty.py; new diagnostics: 0): the commit hook passed
  • Pure move only: move-check summary (python scripts/dev/check_move.py origin/master --markdown): not a pure move
  • Overlap check done: python scripts/dev/pr_overlap.py shows no open PR on the same files
  • CI is fully green before review is requested

AI disclosure

  • AI tools were used for: the whole change, authored by Claude Code under the user's direction. No Co-authored-by AI tags are in the commits.

Skipped hooks

none

Both image entrypoints generated config.jsonc and printed 'Edit ... restart the container' before any command, including llm-rosetta ext install and llm-rosetta gateway --help. The template belongs to the default start: the default CMD, an argument list that holds only options, and an explicit serve (also gateway serve). Every other command runs without it. The config directory is CONFIG_DIR (default /config), which the shell tests set to a temporary directory.
@Oaklight
Oaklight merged commit 37f3645 into master Nov 26, 2026
14 checks passed
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.

1 participant