Sha256: e5e437589f5359346da1f5561fb42fe7d9f8a145d389cdf14b339fa88cf6920f
Contents?: true
Size: 1.54 KB
Versions: 11
Compression:
Stored size: 1.54 KB
Contents
module Dockit class Image attr_reader :image class << self def list(all: false, filters: nil) Docker::Image.all(all: all, filters: JSON.dump(filters)) end def create(config) unless config STDERR.puts "No build target configured" return end repos = config['t'] puts "Building #{repos}" convert_buildargs(config) begin image = Docker::Image.build_from_dir('.', config) do |chunk| Dockit::Log.print_chunk(chunk) end rescue Docker::Error::TimeoutError => e $stderr.puts '* Read timeout, try again with a larger "--timeout"' exit 1 rescue Docker::Error::UnexpectedResponseError => e $stderr.puts 'Build error, exiting.' exit 1 end image end def get(name) Docker::Image.get(name) end def clean(force: false, except: []) except ||= [] puts "Images..." list( all: force, filters: force ? nil : {dangling: ['true']} ).each do |image| names = image.info["RepoTags"]||[] puts " #{image.id}" if (names & except).count > 0 puts " ... skipping #{names}" next end image.remove(force: true) end end private def convert_buildargs(config) return unless args = config['buildargs'] return if args.is_a?(String) config['buildargs'] = args.to_json end end end end
Version data entries
11 entries across 11 versions & 1 rubygems