Class: Panoramix::Plugin::DockerBuild

Inherits:
DockerImageBase show all
Defined in:
lib/panoramix/plugin/docker_build.rb

Instance Attribute Summary collapse

Attributes inherited from DockerImageBase

#dst, #tag

Instance Method Summary collapse

Methods inherited from DockerImageBase

#clobber, #created?, #timestamp

Methods inherited from Base

#created?, #shell, #timestamp

Constructor Details

#initialize(dst, dockerfile, context, host) ⇒ DockerBuild

Returns a new instance of DockerBuild.



12
13
14
15
16
17
18
# File 'lib/panoramix/plugin/docker_build.rb', line 12

def initialize(dst, dockerfile, context, host)
  super(dst, host)
  @dockerfile = dockerfile 
  @context = context
  @env = Hash.new
  @env["DOCKER_HOST"] = "tcp://#{host}" if host
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



9
10
11
# File 'lib/panoramix/plugin/docker_build.rb', line 9

def context
  @context
end

#dockerfileObject (readonly)

Returns the value of attribute dockerfile.



10
11
12
# File 'lib/panoramix/plugin/docker_build.rb', line 10

def dockerfile
  @dockerfile
end

#envObject (readonly)

Returns the value of attribute env.



8
9
10
# File 'lib/panoramix/plugin/docker_build.rb', line 8

def env
  @env
end

Instance Method Details

#needed?(timestamps) ⇒ Boolean

When this instance needs to be executed

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/panoramix/plugin/docker_build.rb', line 21

def needed? timestamps
  return false if ENV['NO_BUILD'] && ENV['NO_BUILD'].split(":").any? { |image| image == @dst }
  return true
end

#psObject



31
32
33
# File 'lib/panoramix/plugin/docker_build.rb', line 31

def ps
  super ("Built image")
end

#run_defaultObject

Default action for this task



27
28
29
# File 'lib/panoramix/plugin/docker_build.rb', line 27

def run_default
  shell("docker build -t #{dst} -f #{@dockerfile} #{@context}", false, @env)
end