Class: LLMExperiment::CLI::BuildCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/llm_experiment/cli/build_command.rb

Constant Summary collapse

NAME =
"build"
SUMMARY =
"build the base image or a per-app image"

Instance Method Summary collapse

Methods inherited from Command

#call, #initialize, summary

Constructor Details

This class inherits a constructor from LLMExperiment::CLI::Command

Instance Method Details

#add_options(parser) ⇒ Object



9
10
11
12
13
# File 'lib/llm_experiment/cli/build_command.rb', line 9

def add_options(parser)
  parser.banner = "Usage: llmx build base [options]\n       llmx build app KEY [options]"
  parser.on("--no-cache", "rebuild every layer") { @no_cache = true }
  parser.on("--tag TAG", "image tag (base only)") { |t| @tag = t }
end

#run(argv) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/llm_experiment/cli/build_command.rb', line 15

def run(argv)
  case argv.shift
  when "base"
    pins = begin
      experiment.pins
    rescue ConfigError
      Pins.resolve
    end
    ImageBuilder::Base.new(container: container)
                      .build(pins: pins, tag: @tag || LLMExperiment.base_image, no_cache: !!@no_cache)
  when "app"
    key = argv.shift or raise Error, "usage: llmx build app KEY"
    ImageBuilder::App.new(experiment: experiment, container: container)
                     .build(app: experiment.app(key), no_cache: !!@no_cache)
  else
    raise Error, "usage: llmx build base | llmx build app KEY"
  end
end