Module: Dapp::Project::Command::Cleanup

Included in:
Dapp::Project
Defined in:
lib/dapp/project/command/cleanup.rb

Overview

Cleanup

Instance Method Summary collapse

Instance Method Details

#cleanupObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dapp/project/command/cleanup.rb', line 8

def cleanup
  build_configs.map(&:_basename).uniq.each do |basename|
    lock("#{basename}.images") do
      log_step_with_indent(basename) do
        project_containers_flush(basename)
        project_dangling_images_flush(basename)
        remove_images_by_query([
          'docker images',
          %(--format '{{if ne "#{stage_cache(basename)}" .Repository }}{{.ID}}{{ end }}'),
          %(-f "label=dapp=#{stage_dapp_label(basename)}")
        ].join(' ')) # FIXME: negative filter is not currently supported by the Docker CLI
      end
    end
  end
end