Class: Buildizer::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/buildizer/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, target, from: nil) ⇒ Image

Returns a new instance of Image.



9
10
11
12
13
14
15
16
17
# File 'lib/buildizer/image.rb', line 9

def initialize(name, target, from: nil)
  @name = name
  @target = target

  @instructions = []
  @from = from

  instruction :FROM, from if from
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



7
8
9
# File 'lib/buildizer/image.rb', line 7

def from
  @from
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



6
7
8
# File 'lib/buildizer/image.rb', line 6

def instructions
  @instructions
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/buildizer/image.rb', line 3

def name
  @name
end

#targetObject (readonly)

Returns the value of attribute target.



4
5
6
# File 'lib/buildizer/image.rb', line 4

def target
  @target
end

Instance Method Details

#build_pathObject



23
24
25
# File 'lib/buildizer/image.rb', line 23

def build_path
  target.image_build_path
end

#dockerfile_dumpObject



39
40
41
# File 'lib/buildizer/image.rb', line 39

def dockerfile_dump
  [instructions, nil].join("\n")
end

#dockerfile_nameObject



31
32
33
# File 'lib/buildizer/image.rb', line 31

def dockerfile_name
  "#{name}.dockerfile"
end

#dockerfile_pathObject



35
36
37
# File 'lib/buildizer/image.rb', line 35

def dockerfile_path
  target.image_work_path.join(dockerfile_name)
end

#dockerfile_write!Object



43
44
45
# File 'lib/buildizer/image.rb', line 43

def dockerfile_write!
  dockerfile_path.write! dockerfile_dump
end

#extra_pathObject



27
28
29
# File 'lib/buildizer/image.rb', line 27

def extra_path
  target.image_extra_path
end

#instruction(instruction, cmd) ⇒ Object



19
20
21
# File 'lib/buildizer/image.rb', line 19

def instruction(instruction, cmd)
  instructions << [instruction.to_s.upcase, cmd].join(' ')
end