Class: Specinfra::Backend::Dockerfile

Inherits:
Base
  • Object
show all
Defined in:
lib/specinfra/backend/dockerfile.rb

Instance Method Summary collapse

Methods inherited from Base

clear, #command, #get_config, #host_inventory, instance, #os_info, #set_config, #set_example, #stderr_handler=, #stdout_handler=

Constructor Details

#initialize(config = {}) ⇒ Dockerfile

Returns a new instance of Dockerfile.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/specinfra/backend/dockerfile.rb', line 4

def initialize(config = {})
  super

  @lines = []
  ObjectSpace.define_finalizer(self) {
    if get_config(:dockerfile_finalizer).nil?
      puts @lines
    else
      get_config(:dockerfile_finalizer).call(@lines)
    end
  }
end

Instance Method Details

#from(base) ⇒ Object



27
28
29
# File 'lib/specinfra/backend/dockerfile.rb', line 27

def from(base)
  @lines << "FROM #{base}"
end

#run_command(cmd, opts = {}) ⇒ Object



17
18
19
20
# File 'lib/specinfra/backend/dockerfile.rb', line 17

def run_command(cmd, opts={})
  @lines << "RUN #{cmd}"
  CommandResult.new
end

#send_file(from, to) ⇒ Object



22
23
24
25
# File 'lib/specinfra/backend/dockerfile.rb', line 22

def send_file(from, to)
  @lines << "ADD #{from} #{to}"
  CommandResult.new
end