ruby_llm-docker 0.0.1 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +255 -11
- data/Rakefile +3 -3
- data/examples/docker_chat.rb +228 -0
- data/examples/list_containers.rb +36 -0
- data/examples/test_chat.rb +81 -0
- data/lib/ruby_llm/docker/build_image.rb +111 -0
- data/lib/ruby_llm/docker/copy_to_container.rb +196 -0
- data/lib/ruby_llm/docker/create_container.rb +146 -0
- data/lib/ruby_llm/docker/create_network.rb +131 -0
- data/lib/ruby_llm/docker/create_volume.rb +129 -0
- data/lib/ruby_llm/docker/exec_container.rb +185 -0
- data/lib/ruby_llm/docker/fetch_container_logs.rb +132 -0
- data/lib/ruby_llm/docker/list_containers.rb +59 -0
- data/lib/ruby_llm/docker/list_images.rb +79 -0
- data/lib/ruby_llm/docker/list_networks.rb +81 -0
- data/lib/ruby_llm/docker/list_volumes.rb +88 -0
- data/lib/ruby_llm/docker/pull_image.rb +127 -0
- data/lib/ruby_llm/docker/push_image.rb +153 -0
- data/lib/ruby_llm/docker/recreate_container.rb +151 -0
- data/lib/ruby_llm/docker/remove_container.rb +120 -0
- data/lib/ruby_llm/docker/remove_image.rb +142 -0
- data/lib/ruby_llm/docker/remove_network.rb +120 -0
- data/lib/ruby_llm/docker/remove_volume.rb +127 -0
- data/lib/ruby_llm/docker/run_container.rb +104 -0
- data/lib/ruby_llm/docker/start_container.rb +97 -0
- data/lib/ruby_llm/docker/stop_container.rb +109 -0
- data/lib/ruby_llm/docker/tag_image.rb +139 -0
- data/lib/ruby_llm/docker/version.rb +2 -2
- data/lib/ruby_llm/docker.rb +53 -3
- data/sig/ruby_llm/docker.rbs +1 -1
- metadata +90 -5
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyLLM
|
|
4
|
+
module Docker
|
|
5
|
+
# RubyLLM tool for tagging Docker images.
|
|
6
|
+
#
|
|
7
|
+
# This tool provides the ability to create new tags for existing Docker images,
|
|
8
|
+
# enabling better organization, versioning, and distribution of images. Tags
|
|
9
|
+
# are essential for image management and registry operations.
|
|
10
|
+
#
|
|
11
|
+
# == Features
|
|
12
|
+
#
|
|
13
|
+
# - Tag images by ID or existing name
|
|
14
|
+
# - Support for repository and tag specification
|
|
15
|
+
# - Force tagging to overwrite existing tags
|
|
16
|
+
# - Registry-compatible tag formatting
|
|
17
|
+
# - Comprehensive error handling
|
|
18
|
+
# - Multiple tags per image support
|
|
19
|
+
#
|
|
20
|
+
# == Tag Management Benefits
|
|
21
|
+
#
|
|
22
|
+
# Proper tagging enables:
|
|
23
|
+
# - **Version Control**: Track different image versions
|
|
24
|
+
# - **Distribution**: Prepare images for registry push
|
|
25
|
+
# - **Organization**: Group related images logically
|
|
26
|
+
# - **Deployment**: Reference specific image versions
|
|
27
|
+
# - **Rollback**: Maintain previous versions for rollback
|
|
28
|
+
#
|
|
29
|
+
# == Security Considerations
|
|
30
|
+
#
|
|
31
|
+
# Tagging affects image accessibility and distribution:
|
|
32
|
+
# - Tags determine registry push destinations
|
|
33
|
+
# - Overwriting tags can affect running containers
|
|
34
|
+
# - Registry-compatible tags expose images for distribution
|
|
35
|
+
# - Tag names may reveal application details
|
|
36
|
+
#
|
|
37
|
+
# Best practices:
|
|
38
|
+
# - Use descriptive but not sensitive tag names
|
|
39
|
+
# - Avoid overwriting production tags accidentally
|
|
40
|
+
# - Implement tag naming conventions
|
|
41
|
+
# - Regular cleanup of unused tags
|
|
42
|
+
# - Control access to critical tag operations
|
|
43
|
+
#
|
|
44
|
+
# == Tag Naming Conventions
|
|
45
|
+
#
|
|
46
|
+
# Recommended patterns:
|
|
47
|
+
# - **Semantic Versioning**: `v1.2.3`, `1.2.3-alpha`
|
|
48
|
+
# - **Environment Tags**: `prod`, `staging`, `dev`
|
|
49
|
+
# - **Feature Tags**: `feature-branch-name`
|
|
50
|
+
# - **Date Tags**: `2024-01-15`, `20240115`
|
|
51
|
+
# - **Commit Tags**: `sha-abc123def`
|
|
52
|
+
#
|
|
53
|
+
# == Example Usage
|
|
54
|
+
#
|
|
55
|
+
# # Tag with version
|
|
56
|
+
# TagImage.call(
|
|
57
|
+
# server_context: context,
|
|
58
|
+
# id: "abc123def456",
|
|
59
|
+
# repo: "myapp",
|
|
60
|
+
# tag: "v1.0.0"
|
|
61
|
+
# )
|
|
62
|
+
#
|
|
63
|
+
# # Tag for registry push
|
|
64
|
+
# TagImage.call(
|
|
65
|
+
# server_context: context,
|
|
66
|
+
# id: "myapp:latest",
|
|
67
|
+
# repo: "myusername/myapp",
|
|
68
|
+
# tag: "production"
|
|
69
|
+
# )
|
|
70
|
+
#
|
|
71
|
+
# # Tag for private registry
|
|
72
|
+
# TagImage.call(
|
|
73
|
+
# server_context: context,
|
|
74
|
+
# id: "webapp:dev",
|
|
75
|
+
# repo: "registry.company.com/team/webapp",
|
|
76
|
+
# tag: "v2.1.0"
|
|
77
|
+
# )
|
|
78
|
+
#
|
|
79
|
+
# @see BuildImage
|
|
80
|
+
# @see PushImage
|
|
81
|
+
# @see Docker::Image#tag
|
|
82
|
+
# @since 0.1.0
|
|
83
|
+
class TagImage < RubyLLM::Tool
|
|
84
|
+
description 'Tag a Docker image'
|
|
85
|
+
|
|
86
|
+
param :id, type: :string, desc: 'Image ID or current name:tag'
|
|
87
|
+
param :repo, type: :string,
|
|
88
|
+
desc: 'Repository name (e.g., "username/imagename" or "registry/username/imagename")'
|
|
89
|
+
param :tag, type: :string, desc: 'Tag for the image (default: "latest")', required: false
|
|
90
|
+
param :force, type: :boolean, desc: 'Force tag even if it already exists (default: true)', required: false
|
|
91
|
+
|
|
92
|
+
# Tag a Docker image with a new repository and tag name.
|
|
93
|
+
#
|
|
94
|
+
# This method creates a new tag for an existing image, allowing it to
|
|
95
|
+
# be referenced by the new name. This is essential for organizing images
|
|
96
|
+
# and preparing them for registry distribution.
|
|
97
|
+
#
|
|
98
|
+
# @param id [String] image ID or current name:tag to tag
|
|
99
|
+
# @param repo [String] repository name for the new tag
|
|
100
|
+
# @param server_context [Object] RubyLLM context (unused but required)
|
|
101
|
+
# @param tag [String] tag name for the image (default: "latest")
|
|
102
|
+
# @param force [Boolean] whether to overwrite existing tags (default: true)
|
|
103
|
+
#
|
|
104
|
+
# @return [RubyLLM::Tool::Response] tagging operation results
|
|
105
|
+
#
|
|
106
|
+
# @raise [Docker::Error::NotFoundError] if source image doesn't exist
|
|
107
|
+
# @raise [StandardError] for other tagging failures
|
|
108
|
+
#
|
|
109
|
+
# @example Tag for versioning
|
|
110
|
+
# response = TagImage.call(
|
|
111
|
+
# server_context: context,
|
|
112
|
+
# id: "my-app:latest",
|
|
113
|
+
# repo: "my-app",
|
|
114
|
+
# tag: "v1.2.3"
|
|
115
|
+
# )
|
|
116
|
+
#
|
|
117
|
+
# @example Tag for registry push
|
|
118
|
+
# response = tool.execute(
|
|
119
|
+
# id: "abc123def456",
|
|
120
|
+
# repo: "myregistry.com/myuser/myapp",
|
|
121
|
+
# tag: "production",
|
|
122
|
+
# force: true
|
|
123
|
+
# )
|
|
124
|
+
#
|
|
125
|
+
# @see Docker::Image#tag
|
|
126
|
+
def execute(id:, repo:, tag: 'latest', force: true)
|
|
127
|
+
image = ::Docker::Image.get(id)
|
|
128
|
+
|
|
129
|
+
image.tag('repo' => repo, 'tag' => tag, 'force' => force)
|
|
130
|
+
|
|
131
|
+
"Image tagged successfully as #{repo}:#{tag}"
|
|
132
|
+
rescue ::Docker::Error::NotFoundError
|
|
133
|
+
"Image #{id} not found"
|
|
134
|
+
rescue StandardError => e
|
|
135
|
+
"Error tagging image: #{e.message}"
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
data/lib/ruby_llm/docker.rb
CHANGED
|
@@ -1,10 +1,60 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require 'ruby_llm'
|
|
4
|
+
require 'docker'
|
|
5
|
+
require 'shellwords'
|
|
6
|
+
require 'zeitwerk'
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
loader = Zeitwerk::Loader.for_gem_extension(RubyLLM)
|
|
9
|
+
loader.setup
|
|
10
|
+
|
|
11
|
+
require_relative 'docker/version'
|
|
12
|
+
|
|
13
|
+
module RubyLLM
|
|
6
14
|
module Docker
|
|
7
15
|
class Error < StandardError; end
|
|
8
|
-
|
|
16
|
+
|
|
17
|
+
# Helper method to get all Docker tool classes
|
|
18
|
+
def self.all_tools
|
|
19
|
+
[
|
|
20
|
+
# Container Management
|
|
21
|
+
ListContainers,
|
|
22
|
+
CreateContainer,
|
|
23
|
+
RunContainer,
|
|
24
|
+
StartContainer,
|
|
25
|
+
StopContainer,
|
|
26
|
+
RemoveContainer,
|
|
27
|
+
RecreateContainer,
|
|
28
|
+
ExecContainer,
|
|
29
|
+
CopyToContainer,
|
|
30
|
+
FetchContainerLogs,
|
|
31
|
+
|
|
32
|
+
# Image Management
|
|
33
|
+
ListImages,
|
|
34
|
+
PullImage,
|
|
35
|
+
BuildImage,
|
|
36
|
+
TagImage,
|
|
37
|
+
PushImage,
|
|
38
|
+
RemoveImage,
|
|
39
|
+
|
|
40
|
+
# Network Management
|
|
41
|
+
ListNetworks,
|
|
42
|
+
CreateNetwork,
|
|
43
|
+
RemoveNetwork,
|
|
44
|
+
|
|
45
|
+
# Volume Management
|
|
46
|
+
ListVolumes,
|
|
47
|
+
CreateVolume,
|
|
48
|
+
RemoveVolume
|
|
49
|
+
]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Helper method to add all Docker tools to a RubyLLM chat instance
|
|
53
|
+
def self.add_all_tools_to_chat(chat)
|
|
54
|
+
all_tools.each do |tool_class|
|
|
55
|
+
chat.with_tool(tool_class)
|
|
56
|
+
end
|
|
57
|
+
chat
|
|
58
|
+
end
|
|
9
59
|
end
|
|
10
60
|
end
|
data/sig/ruby_llm/docker.rbs
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,74 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_llm-docker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aaron F Stanton
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: base64
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: docker-api
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: ruby_llm
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: zeitwerk
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
description: A comprehensive Ruby gem that provides Docker management capabilities
|
|
69
|
+
through RubyLLM tools. Enables AI assistants to interact with Docker containers,
|
|
70
|
+
images, networks, and volumes using natural language. Ported from DockerMCP to work
|
|
71
|
+
directly with RubyLLM without requiring an external MCP server.
|
|
14
72
|
email:
|
|
15
73
|
- afstanton@gmail.com
|
|
16
74
|
executables: []
|
|
@@ -20,7 +78,32 @@ files:
|
|
|
20
78
|
- LICENSE.txt
|
|
21
79
|
- README.md
|
|
22
80
|
- Rakefile
|
|
81
|
+
- examples/docker_chat.rb
|
|
82
|
+
- examples/list_containers.rb
|
|
83
|
+
- examples/test_chat.rb
|
|
23
84
|
- lib/ruby_llm/docker.rb
|
|
85
|
+
- lib/ruby_llm/docker/build_image.rb
|
|
86
|
+
- lib/ruby_llm/docker/copy_to_container.rb
|
|
87
|
+
- lib/ruby_llm/docker/create_container.rb
|
|
88
|
+
- lib/ruby_llm/docker/create_network.rb
|
|
89
|
+
- lib/ruby_llm/docker/create_volume.rb
|
|
90
|
+
- lib/ruby_llm/docker/exec_container.rb
|
|
91
|
+
- lib/ruby_llm/docker/fetch_container_logs.rb
|
|
92
|
+
- lib/ruby_llm/docker/list_containers.rb
|
|
93
|
+
- lib/ruby_llm/docker/list_images.rb
|
|
94
|
+
- lib/ruby_llm/docker/list_networks.rb
|
|
95
|
+
- lib/ruby_llm/docker/list_volumes.rb
|
|
96
|
+
- lib/ruby_llm/docker/pull_image.rb
|
|
97
|
+
- lib/ruby_llm/docker/push_image.rb
|
|
98
|
+
- lib/ruby_llm/docker/recreate_container.rb
|
|
99
|
+
- lib/ruby_llm/docker/remove_container.rb
|
|
100
|
+
- lib/ruby_llm/docker/remove_image.rb
|
|
101
|
+
- lib/ruby_llm/docker/remove_network.rb
|
|
102
|
+
- lib/ruby_llm/docker/remove_volume.rb
|
|
103
|
+
- lib/ruby_llm/docker/run_container.rb
|
|
104
|
+
- lib/ruby_llm/docker/start_container.rb
|
|
105
|
+
- lib/ruby_llm/docker/stop_container.rb
|
|
106
|
+
- lib/ruby_llm/docker/tag_image.rb
|
|
24
107
|
- lib/ruby_llm/docker/version.rb
|
|
25
108
|
- sig/ruby_llm/docker.rbs
|
|
26
109
|
homepage: https://github.com/afstanton/ruby_llm-docker
|
|
@@ -30,6 +113,7 @@ metadata:
|
|
|
30
113
|
allowed_push_host: https://rubygems.org
|
|
31
114
|
homepage_uri: https://github.com/afstanton/ruby_llm-docker
|
|
32
115
|
source_code_uri: https://github.com/afstanton/ruby_llm-docker
|
|
116
|
+
rubygems_mfa_required: 'true'
|
|
33
117
|
rdoc_options: []
|
|
34
118
|
require_paths:
|
|
35
119
|
- lib
|
|
@@ -46,5 +130,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
46
130
|
requirements: []
|
|
47
131
|
rubygems_version: 3.7.2
|
|
48
132
|
specification_version: 4
|
|
49
|
-
summary:
|
|
133
|
+
summary: Docker management tools for RubyLLM - comprehensive container, image, network,
|
|
134
|
+
and volume operations
|
|
50
135
|
test_files: []
|