Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit c753642

Browse files
authored
Merge pull request #108 from docker/context-size
Adds --context-size option to package command
2 parents 2759382 + b06e60a commit c753642

File tree

10 files changed

+44
-7
lines changed

10 files changed

+44
-7
lines changed

commands/package.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func newPackagedCmd() *cobra.Command {
1818
var opts packageOptions
1919

2020
c := &cobra.Command{
21-
Use: "package --gguf <path> [--license <path>...] --push TARGET",
21+
Use: "package --gguf <path> [--license <path>...] [--context-size <tokens>] --push TARGET",
2222
Short: "Package a GGUF file into a Docker model OCI artifact, with optional licenses, and pushes it to the specified registry",
2323
Args: func(cmd *cobra.Command, args []string) error {
2424
if len(args) != 1 {
@@ -72,13 +72,15 @@ func newPackagedCmd() *cobra.Command {
7272
c.Flags().StringVar(&opts.ggufPath, "gguf", "", "absolute path to gguf file (required)")
7373
c.Flags().StringArrayVarP(&opts.licensePaths, "license", "l", nil, "absolute path to a license file")
7474
c.Flags().BoolVar(&opts.push, "push", false, "push to registry (required)")
75+
c.Flags().Uint64Var(&opts.contextSize, "context-size", 0, "context size in tokens")
7576
return c
7677
}
7778

7879
type packageOptions struct {
7980
ggufPath string
8081
licensePaths []string
8182
push bool
83+
contextSize uint64
8284
}
8385

8486
func packageModel(cmd *cobra.Command, tag string, opts packageOptions) error {
@@ -97,6 +99,12 @@ func packageModel(cmd *cobra.Command, tag string, opts packageOptions) error {
9799
return fmt.Errorf("add gguf file: %w", err)
98100
}
99101

102+
// Set context size
103+
if opts.contextSize > 0 {
104+
cmd.PrintErrf("Setting context size %d\n", opts.contextSize)
105+
pkg = pkg.WithContextSize(opts.contextSize)
106+
}
107+
100108
// Add license files
101109
for _, path := range opts.licensePaths {
102110
cmd.PrintErrf("Adding license file from %q\n", path)

docs/reference/docker_model_package.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ short: |
33
Package a GGUF file into a Docker model OCI artifact, with optional licenses, and pushes it to the specified registry
44
long: |
55
Package a GGUF file into a Docker model OCI artifact, with optional licenses, and pushes it to the specified registry
6-
usage: docker model package --gguf <path> [--license <path>...] --push TARGET
6+
usage: docker model package --gguf <path> [--license <path>...] [--context-size <tokens>] --push TARGET
77
pname: docker model
88
plink: docker_model.yaml
99
options:
10+
- option: context-size
11+
value_type: uint64
12+
default_value: "0"
13+
description: context size in tokens
14+
deprecated: false
15+
hidden: false
16+
experimental: false
17+
experimentalcli: false
18+
kubernetes: false
19+
swarm: false
1020
- option: gguf
1121
value_type: string
1222
description: absolute path to gguf file (required)

docs/reference/model_package.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Package a GGUF file into a Docker model OCI artifact, with optional licenses, an
77

88
| Name | Type | Default | Description |
99
|:------------------|:--------------|:--------|:--------------------------------------|
10+
| `--context-size` | `uint64` | `0` | context size in tokens |
1011
| `--gguf` | `string` | | absolute path to gguf file (required) |
1112
| `-l`, `--license` | `stringArray` | | absolute path to a license file |
1213
| `--push` | `bool` | | push to registry (required) |

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ go 1.24
55
toolchain go1.24.4
66

77
require (
8+
github.com/containerd/errdefs v1.0.0
89
github.com/docker/cli v28.3.0+incompatible
910
github.com/docker/cli-docs-tool v0.10.0
1011
github.com/docker/docker v28.2.2+incompatible
1112
github.com/docker/go-connections v0.5.0
1213
github.com/docker/go-units v0.5.0
13-
github.com/docker/model-distribution v0.0.0-20250627131521-63daf278071c
14+
github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0
1415
github.com/docker/model-runner v0.0.0-20250627142917-26a0a73fbbc0
1516
github.com/google/go-containerregistry v0.20.6
1617
github.com/mattn/go-isatty v0.0.17
@@ -31,7 +32,6 @@ require (
3132
github.com/StackExchange/wmi v1.2.1 // indirect
3233
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3334
github.com/containerd/containerd/v2 v2.1.3 // indirect
34-
github.com/containerd/errdefs v1.0.0 // indirect
3535
github.com/containerd/errdefs/pkg v0.3.0 // indirect
3636
github.com/containerd/log v0.1.0 // indirect
3737
github.com/containerd/platforms v1.0.0-rc.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHz
7878
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
7979
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
8080
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
81-
github.com/docker/model-distribution v0.0.0-20250627131521-63daf278071c h1:10BRwHXbCRdIQMvYNjOSPFnGd7ncpc3N7kKG27LQRZY=
82-
github.com/docker/model-distribution v0.0.0-20250627131521-63daf278071c/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
81+
github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0 h1:bve4JZI06Admw+NewtPfrpJXsvRnGKTQvBOEICNC1C0=
82+
github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
8383
github.com/docker/model-runner v0.0.0-20250627142917-26a0a73fbbc0 h1:yajuhlGe1xhpWW3eMehQi2RrqiBQiGoi6c6OWiPxMaQ=
8484
github.com/docker/model-runner v0.0.0-20250627142917-26a0a73fbbc0/go.mod h1:vZJiUZH/7O1CyNsEGi1o4khUT4DVRjcwluuamU9fhuM=
8585
github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM=

vendor/github.com/docker/model-distribution/builder/builder.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/internal/mutate/model.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/internal/mutate/mutate.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/model-distribution/types/config.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ github.com/docker/go-connections/tlsconfig
144144
# github.com/docker/go-units v0.5.0
145145
## explicit
146146
github.com/docker/go-units
147-
# github.com/docker/model-distribution v0.0.0-20250627131521-63daf278071c
147+
# github.com/docker/model-distribution v0.0.0-20250627163720-aff34abcf3e0
148148
## explicit; go 1.23.0
149149
github.com/docker/model-distribution/builder
150150
github.com/docker/model-distribution/distribution

0 commit comments

Comments
 (0)