Class: Lux::DockerImageTask

Inherits:
Rake::FileTask
  • Object
show all
Defined in:
lib/lux/docker_tasks.rb

Instance Method Summary collapse

Constructor Details

#initialize(task_name, app) ⇒ DockerImageTask

This task checks to see if the image is present in the local Docker Server If present it returns the creation date as the timestamp, if not then it returns Rake::Early. This allows dependencies to execute correctly The action block should build the container.



46
47
48
49
50
51
52
# File 'lib/lux/docker_tasks.rb', line 46

def initialize(task_name, app)
  super(task_name, app)
  @imagename = @name
  @imagename += ':latest' unless @imagename.index(':')
  @image = DISABLED ? nil :
      Docker::Image.all.select{|i| i.info['RepoTags']&.include? @imagename}.first
end

Instance Method Details

#needed?Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/lux/docker_tasks.rb', line 54

def needed?
  return false if DISABLED
  ! @image || out_of_date?(timestamp) || @application.options.build_all
end

#timestampObject



59
60
61
62
63
64
65
66
# File 'lib/lux/docker_tasks.rb', line 59

def timestamp
  return Time.now if DISABLED
  if @image = Docker::Image.all.select{|i| i.info['RepoTags']&.include? @imagename}.first
    Time.at(@image.info['Created'])
  else
    Rake::EARLY
  end
end