Class: LLMExperiment::ImageBuilder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_experiment/image_builder/base.rb

Overview

Builds and smoke-checks the base image. Compiles the rubies from source, so the first build is 15-30 minutes and every later one is cached.

Constant Summary collapse

NEED_GB =

Compiling two rubies from source measured about 8 GB. Less than an app image, but it is the longest build in the tool, so losing it to a full disk costs the most.

10

Instance Method Summary collapse

Constructor Details

#initialize(container: Container.new, shell: Shell) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/llm_experiment/image_builder/base.rb', line 8

def initialize(container: Container.new, shell: Shell)
  @container = container
  @shell = shell
end

Instance Method Details

#build(pins:, tag: LLMExperiment.base_image, no_cache: false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/llm_experiment/image_builder/base.rb', line 18

def build(pins:, tag: LLMExperiment.base_image, no_cache: false)
  @container.ensure_disk!(need_gb: NEED_GB)
  @container.ensure_builder!
  @shell.log "building #{tag} (compiles #{pins["ruby_versions"].join(" ")} from source; expect 15-30 min cold)"
  @container.build(
    tag: tag,
    file: LLMExperiment.template_path("base.Containerfile"),
    context: File.dirname(LLMExperiment.template_path("base.Containerfile")),
    build_args: {
      "RUBY_VERSIONS" => pins["ruby_versions"].join(" "),
      "NODE_VERSION" => pins["node"],
      "CLAUDE_CODE_VERSION" => pins["claude_code"],
      "CODEX_VERSION" => pins["codex"],
      "OPENCODE_VERSION" => pins["opencode"]
    },
    no_cache: no_cache
  )
  smoke_check(tag, pins)
  @shell.log "base image ready: #{tag}"
end