Use image tag to determine stale containers
Use current_running_version to determine the latest version when finding stale containers.
This commit is contained in:
@@ -49,9 +49,7 @@ class Kamal::Commands::App < Kamal::Commands::Base
|
||||
|
||||
|
||||
def current_running_container_id
|
||||
pipe \
|
||||
shell(chain(latest_image_container_id, latest_container_id)),
|
||||
[ :head, "-1" ]
|
||||
current_running_container(format: "--quiet")
|
||||
end
|
||||
|
||||
def container_id_for_version(version, only_running: false)
|
||||
@@ -60,8 +58,7 @@ class Kamal::Commands::App < Kamal::Commands::Base
|
||||
|
||||
def current_running_version
|
||||
pipe \
|
||||
shell(chain(latest_image_container_name, latest_container_name)),
|
||||
[ :head, "-1" ],
|
||||
current_running_container(format: "--format '{{.Names}}'"),
|
||||
extract_version_from_name
|
||||
end
|
||||
|
||||
@@ -90,28 +87,18 @@ class Kamal::Commands::App < Kamal::Commands::Base
|
||||
docker :image, :ls, *argumentize("--filter", "reference=#{config.latest_image}"), "--format", "'{{.ID}}'"
|
||||
end
|
||||
|
||||
def latest_image_container_id
|
||||
latest_image_container format: "--quiet"
|
||||
def current_running_container(format:)
|
||||
pipe \
|
||||
shell(chain(latest_image_container(format: format), latest_container(format: format))),
|
||||
[ :head, "-1" ]
|
||||
end
|
||||
|
||||
def latest_container_id
|
||||
latest_container format: "--quiet"
|
||||
def latest_image_container(format:)
|
||||
latest_container format: format, filters: [ "ancestor=$(#{latest_image_id.join(" ")})" ]
|
||||
end
|
||||
|
||||
def latest_image_container_name
|
||||
latest_image_container format: "--format '{{.Names}}'"
|
||||
end
|
||||
|
||||
def latest_container_name
|
||||
latest_container format: "--format '{{.Names}}'"
|
||||
end
|
||||
|
||||
def latest_image_container(format: nil)
|
||||
docker :ps, "--latest", *format, *filter_args(statuses: ACTIVE_DOCKER_STATUSES), "--filter", "ancestor=$(#{latest_image_id.join(" ")})"
|
||||
end
|
||||
|
||||
def latest_container(format:)
|
||||
docker :ps, "--latest", *format, *filter_args(statuses: ACTIVE_DOCKER_STATUSES)
|
||||
def latest_container(format:, filters: nil)
|
||||
docker :ps, "--latest", *format, *filter_args(statuses: ACTIVE_DOCKER_STATUSES), argumentize("--filter", filters)
|
||||
end
|
||||
|
||||
def filter_args(statuses: nil)
|
||||
|
||||
Reference in New Issue
Block a user