Tag images with service label so we can prune exclusively
This commit is contained in:
@@ -6,10 +6,18 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
||||
end
|
||||
|
||||
def build_options
|
||||
[ *build_tags, *build_args, *build_secrets ]
|
||||
[ *build_tags, *build_labels, *build_args, *build_secrets ]
|
||||
end
|
||||
|
||||
private
|
||||
def build_tags
|
||||
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
||||
end
|
||||
|
||||
def build_labels
|
||||
argumentize "--label", { service: config.service }
|
||||
end
|
||||
|
||||
def build_args
|
||||
argumentize "--build-arg", args, redacted: true
|
||||
end
|
||||
@@ -18,10 +26,6 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
||||
argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
|
||||
end
|
||||
|
||||
def build_tags
|
||||
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
||||
end
|
||||
|
||||
def args
|
||||
(config.builder && config.builder["args"]) || {}
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class Mrsk::Commands::Prune < Mrsk::Commands::Base
|
||||
PRUNE_CONTAINERS_AFTER = 3.days.in_hours.to_i
|
||||
|
||||
def images
|
||||
docker :image, :prune, "--all", "--force", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
|
||||
docker :image, :prune, "--all", "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
|
||||
end
|
||||
|
||||
def containers
|
||||
|
||||
Reference in New Issue
Block a user