Sha256: 91dba2300c7697c26f15131968aa1f04ee7d9bdb6320f1e807738c91725fef0a

Contents?: true

Size: 1023 Bytes

Versions: 13

Compression:

Stored size: 1023 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)
        execute *KAMAL.prune.healthcheck_containers
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kamal-1.9.2 lib/kamal/cli/prune.rb
kamal-1.9.1 lib/kamal/cli/prune.rb
kamal-1.9.0 lib/kamal/cli/prune.rb
kamal-2.0.0.alpha lib/kamal/cli/prune.rb
kamal-1.8.3 lib/kamal/cli/prune.rb
kamal-1.8.2 lib/kamal/cli/prune.rb
kamal-1.8.1 lib/kamal/cli/prune.rb
kamal-1.8.0 lib/kamal/cli/prune.rb
kamal-1.7.3 lib/kamal/cli/prune.rb
kamal-1.7.2 lib/kamal/cli/prune.rb
kamal-1.7.1 lib/kamal/cli/prune.rb
kamal-1.7.0 lib/kamal/cli/prune.rb
kamal-1.6.0 lib/kamal/cli/prune.rb