Sha256: 9e99ac9bdaf5b25ff189b7249ff99038b4160dcd0caf9767b6910b89f9ccd5bc

Contents?: true

Size: 971 Bytes

Versions: 22

Compression:

Stored size: 971 Bytes

Contents

class Kamal::Cli::Prune < Kamal::Cli::Base
  desc "all", "Prune unused images and stopped containers"
  def all
    with_lock do
      containers
      images
    end
  end

  desc "images", "Prune unused images"
  def images
    with_lock do
      on(KAMAL.hosts) do
        execute *KAMAL.auditor.record("Pruned images"), verbosity: :debug
        execute *KAMAL.prune.dangling_images
        execute *KAMAL.prune.tagged_images
      end
    end
  end

  desc "containers", "Prune all stopped containers, except the last n (default 5)"
  option :retain, type: :numeric, default: nil, desc: "Number of containers to retain"
  def containers
    retain = options.fetch(:retain, KAMAL.config.retain_containers)
    raise "retain must be at least 1" if retain < 1

    with_lock do
      on(KAMAL.hosts) do
        execute *KAMAL.auditor.record("Pruned containers"), verbosity: :debug
        execute *KAMAL.prune.app_containers(retain: retain)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
kamal-2.5.3 lib/kamal/cli/prune.rb
kamal-2.5.2 lib/kamal/cli/prune.rb
kamal-2.5.1 lib/kamal/cli/prune.rb
kamal-2.5.0 lib/kamal/cli/prune.rb
kamal-2.4.0 lib/kamal/cli/prune.rb
nocoffee-kamal-2.3.0.3 lib/kamal/cli/prune.rb
nocoffee-kamal-2.3.0.2 lib/kamal/cli/prune.rb
nocoffee-kamal-2.3.0.1 lib/kamal/cli/prune.rb
kamal-2.3.0 lib/kamal/cli/prune.rb
kamal-2.2.2 lib/kamal/cli/prune.rb
kamal-2.2.1 lib/kamal/cli/prune.rb
kamal-2.2.0 lib/kamal/cli/prune.rb
kamal-2.1.2 lib/kamal/cli/prune.rb
kamal-2.1.1 lib/kamal/cli/prune.rb
kamal-2.1.0 lib/kamal/cli/prune.rb
kamal-2.0.0 lib/kamal/cli/prune.rb
kamal-2.0.0.rc4 lib/kamal/cli/prune.rb
kamal-2.0.0.rc3 lib/kamal/cli/prune.rb
kamal-2.0.0.rc2 lib/kamal/cli/prune.rb
kamal-2.0.0.rc1 lib/kamal/cli/prune.rb