Class: FPM::Fry::DockerFile::Source
- Inherits:
-
Struct
- Object
- Struct
- FPM::Fry::DockerFile::Source
- Defined in:
- lib/fpm/fry/docker_file.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
- #dockerfile ⇒ Object
-
#initialize(variables, cache = Source::Null::Cache) ⇒ Source
constructor
A new instance of Source.
- #map_from(dir) ⇒ Object
- #map_to(dir) ⇒ Object
- #self_tar_io ⇒ Object
- #tar_io ⇒ Object
Constructor Details
#initialize(variables, cache = Source::Null::Cache) ⇒ Source
Returns a new instance of Source.
14 15 16 17 18 19 20 21 |
# File 'lib/fpm/fry/docker_file.rb', line 14 def initialize(variables, cache = Source::Null::Cache) variables = variables.dup if variables[:distribution] && !variables[:flavour] && OsDb[variables[:distribution]] variables[:flavour] = OsDb[variables[:distribution]][:flavour] end variables.freeze super(variables, cache) end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache
12 13 14 |
# File 'lib/fpm/fry/docker_file.rb', line 12 def cache @cache end |
#variables ⇒ Object
Returns the value of attribute variables
12 13 14 |
# File 'lib/fpm/fry/docker_file.rb', line 12 def variables @variables end |
Instance Method Details
#dockerfile ⇒ Object
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" cache.file_map.each do |from, to| df << "ADD #{map_from(from)} #{map_to(to)}" end df << "" return df.join("\n") end |
#map_from(dir) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/fpm/fry/docker_file.rb', line 63 def map_from(dir) if dir == '' return '.' else return dir end end |
#map_to(dir) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/fpm/fry/docker_file.rb', line 55 def map_to(dir) if ['','.'].include? dir return '/tmp/build' else return File.join('/tmp/build',dir) end end |
#self_tar_io ⇒ Object
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 |