Class: DockerDeploy::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_deploy/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



5
6
7
8
9
10
11
# File 'lib/docker_deploy/context.rb', line 5

def initialize
  @stages = []
  @env_files = []
  @variables = {}
  @ports = {}
  @links = {}
end

Instance Attribute Details

#env_filesObject (readonly)

Returns the value of attribute env_files.



3
4
5
# File 'lib/docker_deploy/context.rb', line 3

def env_files
  @env_files
end

Returns the value of attribute links.



3
4
5
# File 'lib/docker_deploy/context.rb', line 3

def links
  @links
end

#portsObject (readonly)

Returns the value of attribute ports.



3
4
5
# File 'lib/docker_deploy/context.rb', line 3

def ports
  @ports
end

#stagesObject (readonly)

Returns the value of attribute stages.



3
4
5
# File 'lib/docker_deploy/context.rb', line 3

def stages
  @stages
end

#variablesObject (readonly)

Returns the value of attribute variables.



3
4
5
# File 'lib/docker_deploy/context.rb', line 3

def variables
  @variables
end

Instance Method Details

#container(name = nil) ⇒ Object



34
35
36
37
# File 'lib/docker_deploy/context.rb', line 34

def container(name = nil)
  @container = name if name
  @container or @image.split("/").last
end

#env(variables = {}) ⇒ Object



13
14
15
# File 'lib/docker_deploy/context.rb', line 13

def env(variables = {})
  @variables.merge!(variables)
end

#env_file(env_file) ⇒ Object



25
26
27
# File 'lib/docker_deploy/context.rb', line 25

def env_file(env_file)
  @env_files.push(env_file)
end

#image(name = nil) ⇒ Object



29
30
31
32
# File 'lib/docker_deploy/context.rb', line 29

def image(name = nil)
  @image = name if name
  @image
end


21
22
23
# File 'lib/docker_deploy/context.rb', line 21

def link(links = {})
  @links.merge!(links)
end

#local(&block) ⇒ Object



43
44
45
46
47
# File 'lib/docker_deploy/context.rb', line 43

def local(&block)
  stage = LocalStage.new(self)
  stage.instance_eval(&block)
  @stages << stage
end

#port(ports = {}) ⇒ Object



17
18
19
# File 'lib/docker_deploy/context.rb', line 17

def port(ports = {})
  @ports.merge!(ports)
end

#revisionObject



39
40
41
# File 'lib/docker_deploy/context.rb', line 39

def revision
  @revision ||= `git rev-parse HEAD`.chomp[0...8]
end

#stage(name, &block) ⇒ Object



49
50
51
52
53
# File 'lib/docker_deploy/context.rb', line 49

def stage(name, &block)
  stage = RemoteStage.new(self, name)
  stage.instance_eval(&block)
  @stages << stage
end