Skip to content

Conversation

@doringeman
Copy link
Contributor

@doringeman doringeman commented Oct 2, 2025

Compared to #165 (comment), this time I used git filter-repo.

Consolidated model-cli (367 commits) + b1f0a10 + a39f8ce +344ca1b + bbb7e9b + 13d99c4 = 372 commits.

Summary by Sourcery

Consolidate the standalone model-cli project into the model-runner monorepo and introduce a fully integrated Docker CLI plugin for managing, running, packaging, and monitoring AI/ML models. This PR imports the entire cmd/cli directory, context detection, standalone runner support, desktop integration, CLI commands, documentation, tests, and CI configuration.

New Features:

  • Import the model-cli code into the monorepo under cmd/cli, including commands: run, pull, push, list, inspect, rm, tag, package, logs, status, configure, compose, install-runner, uninstall-runner, requests, ps, df, unload, and version.
  • Implement ModelRunnerContext and DockerDesktop integration to route requests via Docker Desktop, Moby, or Cloud contexts.
  • Enable standalone mode support under pkg/standalone for auto-installing and managing a model-runner controller container, images, and storage volumes.
  • Add interactive chat with streaming markdown rendering and multi-line input support for the run command.
  • Provide GGUF packaging into OCI artifacts with direct load to model-runner or push to registry.

Enhancements:

  • Introduce completion functions, JSON/YAML formatters, and utility helpers for unified CLI behavior.
  • Enhance progress reporting and error handling across pull, push, package, and chat operations.

Build:

  • Add Makefile, docker-bake.hcl, Dockerfile, and release targets to build and distribute the CLI as a Docker CLI plugin.

CI:

  • Add GitHub Actions workflows for CLI validation, multi-platform builds, and Docker Bake configuration.

Documentation:

  • Generate and import extensive CLI reference documentation in Markdown and YAML under cmd/cli/docs/reference for all commands.

Tests:

  • Add comprehensive unit tests for desktop client operations (pull, push, inspect, chat, remove, tag) and command utilities (status, run multiline input).

Chores:

  • Update go.mod and go.sum to vendor all new dependencies for the integrated CLI and ensure reproducible builds.

xenoscopic and others added 30 commits May 12, 2025 09:49
This commit adds detection of the Model Runner context. It supports a
variety of scenarios, including Docker Desktop, Docker Cloud, vanilla
Moby, and Moby with some sort of manually initialized model runner.

To facilitate this, a little bit of refactoring was required to properly
initialize the CLI plugin framework. The standalone mode behavior has
also been tweaked to support global Docker options (such as --context)
that would be unavailable without a top-level docker command.

Signed-off-by: Jacob Howard <[email protected]>
Co-authored-by: Dorin-Andrei Geman <[email protected]>
Co-authored-by: Dorin-Andrei Geman <[email protected]>
[AIE-186] Add detection of Model Runner context
Most systems won't have NVIDIA GPUs and this behavior better aligns with
what's done in Docker Desktop.

Signed-off-by: Jacob Howard <[email protected]>
Add `docker model package` command
This commit also adds some uninstall functionality.

Signed-off-by: Jacob Howard <[email protected]>
Also add a mechanism to treat Docker Desktop as Moby for testing.

Signed-off-by: Jacob Howard <[email protected]>
Signed-off-by: Jacob Howard <[email protected]>
Signed-off-by: Jacob Howard <[email protected]>
Co-authored-by: Dorin-Andrei Geman <[email protected]>
Copilot AI review requested due to automatic review settings October 2, 2025 10:42
Copy link
Contributor

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

Copilot reviewed 95 out of 4350 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

buildkitd-flags: --debug
-
name: Validate
uses: docker/bake-action@v6

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Validate model-cli' step
Uses Step
uses 'docker/bake-action' with ref 'v6', not a pinned commit hash
Copilot AI review requested due to automatic review settings October 2, 2025 10:58
Copy link
Contributor

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

Copilot reviewed 95 out of 4350 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Signed-off-by: Dorin Geman <[email protected]>
@p1-0tr
Copy link

p1-0tr commented Oct 2, 2025

Hmm, I wonder if stripping vendor/* out wouldn't be a good idea

Signed-off-by: Dorin Geman <[email protected]>
Signed-off-by: Dorin Geman <[email protected]>
Copilot AI review requested due to automatic review settings October 3, 2025 08:27
Copy link
Contributor

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

Copilot reviewed 96 out of 97 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@doringeman doringeman marked this pull request as ready for review October 3, 2025 12:46
Copilot AI review requested due to automatic review settings October 3, 2025 12:46
Copy link
Contributor

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

Copilot reviewed 95 out of 96 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@doringeman doringeman merged commit 1546dfc into main Oct 3, 2025
8 checks passed
@doringeman doringeman deleted the monorepo-model-cli branch October 3, 2025 12:48
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 3, 2025

Reviewer's Guide

This PR merges the standalone model-cli repository into the model-runner monorepo using git filter-repo, reorganizing the CLI under cmd/cli and introducing all related code, tests, documentation, and CI/build configuration.

Class diagram for ModelRunnerContext and Client in desktop package

classDiagram
  class ModelRunnerContext {
    +kind: ModelRunnerEngineKind
    +urlPrefix: *url.URL
    +client: DockerHttpClient
    +EngineKind()
    +URL(path string) string
    +Client() DockerHttpClient
  }
  class Client {
    +modelRunner: ModelRunnerContext
    +Status() Status
    +Pull(model string, ignoreRuntimeMemoryCheck bool, progress func(string)) (string, bool, error)
    +Push(model string, progress func(string)) (string, bool, error)
    +List() ([]Model, error)
    +ListOpenAI(backend, apiKey string) (OpenAIModelList, error)
    +Inspect(model string, remote bool) (Model, error)
    +InspectOpenAI(model string) (OpenAIModel, error)
    +Chat(backend, model, prompt, apiKey string, outputFunc func(string), shouldUseMarkdown bool) error
    +Remove(models []string, force bool) (string, error)
    +PS() ([]BackendStatus, error)
    +DF() (DiskUsage, error)
    +Unload(req UnloadRequest) (UnloadResponse, error)
    +ConfigureBackend(request ConfigureRequest) error
    +Requests(modelFilter string, streaming bool, includeExisting bool) (io.ReadCloser, func(), error)
    +Tag(source, targetRepo, targetTag string) error
    +LoadModel(ctx context.Context, r io.Reader) error
  }
  ModelRunnerContext <|-- Client
  class Status {
    +Running: bool
    +Status: []byte
    +Error: error
  }
  class BackendStatus {
    +BackendName: string
    +ModelName: string
    +Mode: string
    +LastUsed: time.Time
  }
  class DiskUsage {
    +ModelsDiskUsage: int64
    +DefaultBackendDiskUsage: int64
  }
  class UnloadRequest {
    +All: bool
    +Backend: string
    +Models: []string
  }
  class UnloadResponse {
    +UnloadedRunners: int
  }
  class ProgressMessage {
    +Type: string
    +Message: string
    +Total: uint64
    +Pulled: uint64
    +Layer: Layer
  }
  class Layer {
    +ID: string
    +Size: uint64
    +Current: uint64
  }
Loading

File-Level Changes

Change Details Files
Monorepo integration and build setup
  • Import entire CLI under cmd/cli preserving history
  • Add go.mod/go.sum for CLI module
  • Introduce Makefile, Dockerfile, and Buildx bake file
  • Configure GitHub workflows for validation and build
go.mod
go.sum
Makefile
docker-bake.hcl
Dockerfile
.github/workflows/cli-validate.yml
.github/workflows/cli-build.yml
Desktop HTTP client and context abstraction
  • Add desktop package for ModelRunnerContext and HTTP helpers
  • Implement HF model name normalization and error handling
  • Define progress and chat request/response types
  • Expose mock context for tests
cmd/cli/desktop/context.go
cmd/cli/desktop/desktop.go
cmd/cli/desktop/api.go
cmd/cli/desktop/version.go
Standalone container orchestration support
  • Implement container/image pull, start, exec and prune logic
  • Manage volumes and labels for model storage
  • Define default ports, GPU detection, and status printers
cmd/cli/pkg/standalone/containers.go
cmd/cli/pkg/standalone/images.go
cmd/cli/pkg/standalone/volumes.go
cmd/cli/pkg/standalone/labels.go
cmd/cli/pkg/standalone/ports.go
cmd/cli/pkg/standalone/status.go
Cobra-based CLI commands
  • Add core commands for model lifecycle (run, pull, push, list, inspect, rm, tag)
  • Implement advanced commands (package, configure, ps, df, unload, logs, compose, requests, version)
  • Wire up global CLI context and Docker plugin integration
cmd/cli/commands/*.go
Utility and support packages
  • Provide shell completion helpers
  • Add JSON formatter for command output
  • Implement GPU probing in pkg/gpu
  • Define engine kind types in pkg/types
cmd/cli/commands/completion/functions.go
cmd/cli/commands/formatter/json.go
cmd/cli/pkg/gpu/gpu.go
cmd/cli/pkg/types/engine.go
Unit and integration tests
  • Add tests for desktop client (pull, chat, inspect, push, remove, tag)
  • Cover multiline input and status command behavior
  • Use GoMock for HTTP client mocking
cmd/cli/desktop/desktop_test.go
cmd/cli/commands/run_test.go
cmd/cli/commands/status_test.go
Documentation and reference material
  • Generate CLI reference under cmd/cli/docs/reference
  • Add docs generation tool and templates
  • Include Markdown/YAML docs for every command
  • Hook docs into CI validation
cmd/cli/docs/generate.go
cmd/cli/docs/reference/**

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

Blocking issues:

  • An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)
  • An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)
  • An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)

General comments:

  • This consolidation PR touches too many areas at once—consider splitting it into smaller, focused PRs (e.g. CLI commands, desktop client, standalone container logic) to make review and testing more manageable.
  • Several streaming routines (e.g. Chat and Requests) use the default bufio.Scanner buffer size; consider replacing them with a buffered reader or increasing the scanner buffer to safely handle larger payloads without truncation.
  • Query‐string parameters are built by manual string concatenation in multiple places; using net/url.Values to construct URLs would be safer and avoid potential encoding issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- This consolidation PR touches too many areas at once—consider splitting it into smaller, focused PRs (e.g. CLI commands, desktop client, standalone container logic) to make review and testing more manageable.
- Several streaming routines (e.g. Chat and Requests) use the default bufio.Scanner buffer size; consider replacing them with a buffered reader or increasing the scanner buffer to safely handle larger payloads without truncation.
- Query‐string parameters are built by manual string concatenation in multiple places; using net/url.Values to construct URLs would be safer and avoid potential encoding issues.

## Individual Comments

### Comment 1
<location> `cmd/cli/docs/reference/model_status.md:17` </location>
<code_context>
+command: docker model status
+short: Check if the Docker Model Runner is running
+long: |
+    Check whether the Docker Model Runner is running and displays the current inference engine.
+usage: docker model status
+pname: docker model
</code_context>

<issue_to_address>
**issue (typo):** Change 'and displays' to 'and display' for grammatical correctness.

Update the sentence to: 'Check whether the Docker Model Runner is running and display the current inference engine.'
</issue_to_address>

### Comment 2
<location> `.github/workflows/cli-validate.yml:38` </location>
<code_context>
        uses: docker/bake-action/subaction/list-targets@v6
</code_context>

<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

*Source: opengrep*
</issue_to_address>

### Comment 3
<location> `.github/workflows/cli-validate.yml:57` </location>
<code_context>
        uses: docker/setup-buildx-action@v3
</code_context>

<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

*Source: opengrep*
</issue_to_address>

### Comment 4
<location> `.github/workflows/cli-validate.yml:62` </location>
<code_context>
        uses: docker/bake-action@v6
</code_context>

<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


## Description

Check whether the Docker Model Runner is running and displays the current inference engine.
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (typo): Change 'and displays' to 'and display' for grammatical correctness.

Update the sentence to: 'Check whether the Docker Model Runner is running and display the current inference engine.'

-
name: List targets
id: generate
uses: docker/bake-action/subaction/list-targets@v6
Copy link
Contributor

Choose a reason for hiding this comment

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

security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

Source: opengrep

uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

Source: opengrep

buildkitd-flags: --debug
-
name: Validate
uses: docker/bake-action@v6
Copy link
Contributor

Choose a reason for hiding this comment

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

security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha): An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

Source: opengrep

aevesdocker pushed a commit to docker/docs that referenced this pull request Oct 6, 2025
<!--Delete sections as needed -->

## Description

<!-- Tell us what you did and why -->

## Related issues or tickets

* docker/model-runner#190
* docker/model-runner#195

## Reviews

<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->

- [ ] Technical review
- [ ] Editorial review
- [ ] Product review

Signed-off-by: CrazyMax <[email protected]>
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.