Sha256: 9aa08b3dd5dbb99b6e11775e3cdc70d96c1267057e69f73a692ba0b8c99a098d

Contents?: true

Size: 929 Bytes

Versions: 16

Compression:

Stored size: 929 Bytes

Contents

module Ufo::Docker
  class Compiler
    def initialize(dockerfile)
      @dockerfile = dockerfile
      @erb_file = "#{dockerfile}.erb"
    end

    def compile
      return unless File.exist?(@erb_file)

      puts "Compiled #{File.basename(@erb_file).color(:green)} to #{File.basename(@dockerfile).color(:green)}"
      path = "#{Ufo.root}/.ufo/state/data.yml"
      vars = YAML.load_file(path)[Ufo.env] if File.exist?(path)
      vars ||= {}
      result = RenderMePretty.result(@erb_file, vars)
      comment =<<~EOL.chop # remove the trailing newline
        # IMPORTANT: This file was generated from #{File.basename(@erb_file)} as a part of running:
        #
        #     ufo ship
        #
        # To update the FROM statement with the latest base docker image use:
        #
        #    ufo docker base
        #
      EOL
      result = "#{comment}\n#{result}"
      IO.write(@dockerfile, result)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ufo-6.1.5 lib/ufo/docker/compiler.rb
ufo-6.1.4 lib/ufo/docker/compiler.rb
ufo-6.1.3 lib/ufo/docker/compiler.rb
ufo-6.1.2 lib/ufo/docker/compiler.rb
ufo-6.1.1 lib/ufo/docker/compiler.rb
ufo-6.1.0 lib/ufo/docker/compiler.rb
ufo-6.0.9 lib/ufo/docker/compiler.rb
ufo-6.0.8 lib/ufo/docker/compiler.rb
ufo-6.0.7 lib/ufo/docker/compiler.rb
ufo-6.0.6 lib/ufo/docker/compiler.rb
ufo-6.0.5 lib/ufo/docker/compiler.rb
ufo-6.0.4 lib/ufo/docker/compiler.rb
ufo-6.0.3 lib/ufo/docker/compiler.rb
ufo-6.0.2 lib/ufo/docker/compiler.rb
ufo-6.0.1 lib/ufo/docker/compiler.rb
ufo-6.0.0 lib/ufo/docker/compiler.rb