Class: FPM::Fry::DockerFile::Source

Inherits:
Struct
  • Object
show all
Defined in:
lib/fpm/fry/docker_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables, cache = Source::Null::Cache) ⇒ Source

Returns a new instance of Source.



13
14
15
16
17
18
19
20
21
# 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

Instance Attribute Details

#cacheObject

Returns the value of attribute cache

Returns:

  • (Object)

    the current value of cache



11
12
13
# File 'lib/fpm/fry/docker_file.rb', line 11

def cache
  @cache
end

#variablesObject

Returns the value of attribute variables

Returns:

  • (Object)

    the current value of variables



11
12
13
# File 'lib/fpm/fry/docker_file.rb', line 11

def variables
  @variables
end

Instance Method Details

#dockerfileObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# 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_ioObject



44
45
46
47
48
49
50
51
52
53
# 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_ioObject



37
38
39
40
41
42
# File 'lib/fpm/fry/docker_file.rb', line 37

def tar_io
  JoinedIO.new(
    self_tar_io,
    cache.tar_io
  )
end