class FPM::Fry::DockerFile::Source
Attributes
logger[R]
Public Class Methods
new(variables, cache = Source::Null::Cache)
click to toggle source
Calls superclass method
# File lib/fpm/fry/docker_file.rb, line 13 def initialize(variables, cache = Source::Null::Cache) variables = variables.dup.freeze super(variables, cache) if cache.respond_to? :logger @logger = cache.logger else @logger = Cabin::Channel.get end end
Public Instance Methods
dockerfile()
click to toggle source
# File lib/fpm/fry/docker_file.rb, line 23 def dockerfile df = [] df << "FROM #{variables[:image]}" df << "RUN mkdir /tmp/build" file_map.each do |from, to| df << "COPY #{map_from(from)} #{map_to(to)}" end df << "" return df.join("\n") end
self_tar_io()
click to toggle source
# File lib/fpm/fry/docker_file.rb, line 44 def self_tar_io sio = StringIO.new tar = Gem::Package::TarWriter.new(sio) tar.add_file(NAME,'0777') do |io| io.write(dockerfile) end #tar.close sio.rewind return sio end
tar_io()
click to toggle source
# File lib/fpm/fry/docker_file.rb, line 37 def tar_io JoinedIO.new( self_tar_io, cache.tar_io ) end
Private Instance Methods
file_map()
click to toggle source
# File lib/fpm/fry/docker_file.rb, line 59 def file_map prefix = "" to = "" if cache.respond_to? :prefix prefix = cache.prefix end if cache.respond_to? :to to = cache.to || "" end fm = cache.file_map if fm.nil? return { prefix => to } end if fm.size == 1 key, value = fm.first key = key.gsub(%r!\A\./|/\z!,'') if ["",".","./"].include?(value) && key == prefix logger.hint("You can remove the file_map: #{fm.inspect} option on source. The given value is the default") end end return fm end
map_from(dir)
click to toggle source
# File lib/fpm/fry/docker_file.rb, line 90 def map_from(dir) if dir == '' return '.' else return dir end end
map_to(dir)
click to toggle source
# File lib/fpm/fry/docker_file.rb, line 82 def map_to(dir) if ['','.'].include? dir return '/tmp/build' else return File.join('/tmp/build',dir) end end