Split out proper Prune command

This commit is contained in:
David Heinemeier Hansson
2023-01-11 16:48:10 +01:00
parent 7d83be2d18
commit 9d3871d667
3 changed files with 17 additions and 4 deletions

View File

@@ -21,5 +21,6 @@ module Mrsk::Commands
end
require "mrsk/commands/app"
require "mrsk/commands/prune"
require "mrsk/commands/traefik"
require "mrsk/commands/registry"

View File

@@ -0,0 +1,13 @@
class Mrsk::Commands::Prune < Mrsk::Commands::Base
PRUNE_IMAGES_AFTER = 30.days.in_hours.to_i
PRUNE_CONTAINERS_AFTER = 3.days.in_hours.to_i
def images
docker :image, :prune, "-f", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
end
def containers
docker :image, :prune, "-f", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
docker :container, :prune, "-f", "--filter", "label=service=#{config.service}", "--filter", "'until=#{PRUNE_CONTAINERS_AFTER}h'"
end
end