From df2bf9ecb0855830cbee791222202665ccb83719 Mon Sep 17 00:00:00 2001 From: Till JS Date: Fri, 20 Mar 2026 21:13:03 +0100 Subject: [PATCH] fix(deploy): fix image size measurement in deploy metrics Use direct image name lookup (:local) instead of docker compose images --format which isn't supported. Fallback via running container inspection. Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/deploy-metrics.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/deploy-metrics.sh b/scripts/deploy-metrics.sh index 5a6617ae8..7c0d7aa65 100755 --- a/scripts/deploy-metrics.sh +++ b/scripts/deploy-metrics.sh @@ -29,14 +29,19 @@ deploy_timer_elapsed() { # Usage: get_image_size_mb get_image_size_mb() { local service="$1" - local image_id size_bytes - # Get the image ID from the running container - image_id=$(docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" images "$service" --format '{{.ID}}' 2>/dev/null | head -1) - if [ -z "$image_id" ]; then - echo "0" - return + local size_bytes + # Try direct image name (compose services use :local) + size_bytes=$(docker image inspect "${service}:local" --format='{{.Size}}' 2>/dev/null || echo "") + # Fallback: try via running container + if [ -z "$size_bytes" ]; then + local container_image + container_image=$(docker inspect "$(docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" ps -q "$service" 2>/dev/null)" --format='{{.Config.Image}}' 2>/dev/null || echo "") + if [ -n "$container_image" ]; then + size_bytes=$(docker image inspect "$container_image" --format='{{.Size}}' 2>/dev/null || echo "0") + else + size_bytes="0" + fi fi - size_bytes=$(docker image inspect "$image_id" --format='{{.Size}}' 2>/dev/null || echo "0") echo "scale=2; $size_bytes / 1048576" | bc 2>/dev/null || echo "0" }