Class: Ufo::Docker::Compiler
- Inherits:
-
Object
- Object
- Ufo::Docker::Compiler
- Defined in:
- lib/ufo/docker/compiler.rb
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(dockerfile) ⇒ Compiler
constructor
A new instance of Compiler.
Constructor Details
#initialize(dockerfile) ⇒ Compiler
Returns a new instance of Compiler.
3 4 5 6 |
# File 'lib/ufo/docker/compiler.rb', line 3 def initialize(dockerfile) @dockerfile = dockerfile @erb_file = "#{dockerfile}.erb" end |
Instance Method Details
#compile ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ufo/docker/compiler.rb', line 8 def compile return unless File.exist?(@erb_file) puts "Compiled #{File.basename(@erb_file).color(:green)} to #{File.basename(@dockerfile).color(:green)}" state = State.new vars = state.read result = RenderMePretty.result(@erb_file, vars) comment =" # IMPORTANT: This file was generated from \#{File.basename(@erb_file)} as a part of running:\n #\n # ufo ship\n #\n # To update the FROM statement with the latest base docker image use:\n #\n # ufo docker base\n #\n EOL\n result = \"\#{comment}\\n\#{result}\"\n IO.write(@dockerfile, result)\nend\n".chop # remove the trailing newline |