Validate the build image

Kamal needs images to have the service label so it can track them for
pruning. Images built by Kamal will have the label, but externally built
ones may not.

Without it images will build up over time. The worst case is an outage
if all the hosts disks fill up at the same time.

We'll add a check for the label and halt if it is not there.
This commit is contained in:
Donal McBreen
2023-09-12 10:45:01 +01:00
parent d96e086945
commit 66291a2aea
5 changed files with 13 additions and 1 deletions

View File

@@ -103,6 +103,10 @@ class CommandsBuilderTest < ActiveSupport::TestCase
builder.push.join(" ")
end
test "validate image" do
assert_equal "docker inspect -f '{{ .Config.Labels.service }}' dhh/app:123 | grep -x app || (echo \"Image dhh/app:123 is missing the `service` label\" && exit 1)", new_builder_command.validate_image.join(" ")
end
private
def new_builder_command(additional_config = {})
Kamal::Commands::Builder.new(Kamal::Configuration.new(@config.merge(additional_config), version: "123"))