Method: Indocker::Images::ImageBuilder#initialize

Defined in:
lib/indocker/images/image_builder.rb

#initialize(name:, configuration:, dir:) ⇒ ImageBuilder

Returns a new instance of ImageBuilder.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/indocker/images/image_builder.rb', line 4

def initialize(name:, configuration:, dir:)
  @configuration = configuration
  @image = Indocker::Images::Image.new(name)
  dockerfile = File.join(dir, 'Dockerfile')

  if File.exists?(dockerfile)
    @image.set_dockerfile(dockerfile)
  end

  build_context = File.join(dir, 'build_context')

  if Dir.exist?(build_context)
    @image.set_build_context(build_context)
  end

  @image.set_tag('latest')
  @configuration.add_image(@image)
end