Class: Indocker::ImageDSL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ImageDSL

Returns a new instance of ImageDSL.



4
5
6
7
# File 'lib/indocker/image/image_dsl.rb', line 4

def initialize(context)
  @context  = context
  @directives = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



9
10
11
12
13
# File 'lib/indocker/image/image_dsl.rb', line 9

def method_missing(method, *args)
  @context.send(method)
rescue
  super
end

Instance Attribute Details

#directives ⇒ Object (readonly)

Returns the value of attribute directives.



2
3
4
# File 'lib/indocker/image/image_dsl.rb', line 2

def directives
  @directives
end

Instance Method Details

#before_build(&block) ⇒ Object



62
63
64
# File 'lib/indocker/image/image_dsl.rb', line 62

def before_build(&block)
  instance_exec &block
end

#cmd(*args) ⇒ Object



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

def cmd(*args)
  @directives << Indocker::DockerDirectives::Cmd.new(*args)
end

#copy(copy_actions) ⇒ Object



39
40
41
42
43
44
# File 'lib/indocker/image/image_dsl.rb', line 39

def copy(copy_actions)
  @directives << Indocker::DockerDirectives::Copy.new(
    context:      @context, 
    copy_actions: copy_actions
  )
end

#copy_compile(copy_actions) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/indocker/image/image_dsl.rb', line 46

def copy_compile(copy_actions)
  @directives << Indocker::DockerDirectives::Copy.new(
    context:      @context, 
    copy_actions: copy_actions,
    compile:      true
  )
end

#docker_cp(container_name, &block) ⇒ Object



66
67
68
# File 'lib/indocker/image/image_dsl.rb', line 66

def docker_cp(container_name, &block)
  @directives << Indocker::PrepareDirectives::DockerCp.new(container_name, @context.build_dir, &block)
end

#entrypoint(*args) ⇒ Object



54
55
56
# File 'lib/indocker/image/image_dsl.rb', line 54

def entrypoint(*args)
  @directives << Indocker::DockerDirectives::Entrypoint.new(*args)
end

#env(*args) ⇒ Object



58
59
60
# File 'lib/indocker/image/image_dsl.rb', line 58

def env(*args)
  @directives << Indocker::DockerDirectives::Env.new(args)
end

#from(*args) ⇒ Object



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

def from(*args)
  @directives << Indocker::DockerDirectives::From.new(*args)
end

#partial(name, opts = {}) ⇒ Object



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

def partial(name, opts = {})
  @directives << Indocker::Directives::Partial.new(name, @context, opts)
end

#run(*args) ⇒ Object



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

def run(*args)
  @directives << Indocker::DockerDirectives::Run.new(*args)
end

#set_arg(key, value) ⇒ Object



15
16
17
# File 'lib/indocker/image/image_dsl.rb', line 15

def set_arg(key, value)
  @context.set_value(key, value)
end

#workdir(*args) ⇒ Object



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

def workdir(*args)
  @directives << Indocker::DockerDirectives::Workdir.new(*args)
end