class Build

Public Instance Methods

build(options) click to toggle source
# File src/commands/build.rb, line 9
def build (options)
    Docker.options[:read_timeout] = 180
    $stdout.print "Building new image\n"        
    file = File.expand_path(options[:fileName], Dir.getwd)
    shuttlConfig = ShuttlDSL.load file, options[:stage]
    shuttlConfig.setEnvFile options[:env]
    # tar = shuttlConfig.makeImage options[:stage], @cwd
    begin
        step = 1
        @image = shuttlConfig.build options[:stage], @cwd, options[:clean] do |v|
            v.strip!
            v = v.gsub('\n', '\\n')
            if RbConfig::CONFIG['host_os'].downcase.include?('darwin')
                $stdout.puts v
            else
                if (log = JSON.parse(v, quirks_mode: false)) && log.has_key?("stream")
                    $stdout.puts log['stream']
                    if log['stream'].include? 'Step'
                        step += 1
                    end
                end
            end
        end
        if !shuttlConfig.getName().nil?
            @image.tag('repo' => shuttlConfig.getName())
        end
        @info['images'][@cwd] = {:image_id => @image.id, :volumes => shuttlConfig.gatherVolume(options[:stage]), :built => Time.now.to_i, :stage => options[:stage]}
    rescue Docker::Error::UnexpectedResponseError => error
        $stderr.puts "Build Failed!".red
    end
end
run(options) click to toggle source
# File src/commands/build.rb, line 41
def run (options)
    self.build options
end