Unverified Commit ccf18b64 authored by Nate Mailhot's avatar Nate Mailhot Committed by GitHub
Browse files

fix: image size reporting (#6333)

parent 832bf80a
......@@ -176,6 +176,8 @@ runs:
- name: Capture Build Metrics
id: metrics
shell: bash
env:
AWS_DEFAULT_REGION: ${{ inputs.aws_default_region }}
run: |
# Create metrics directory
......@@ -195,11 +197,34 @@ runs:
echo " End: ${BUILD_END_TIME}"
echo " Duration: ${BUILD_DURATION_SEC} seconds"
# Get image size using docker inspect
# Get image size
IMAGE_TAG="${{ steps.build.outputs.image_tag }}"
IMAGE_SIZE_TYPE="unknown"
if [ -n "$IMAGE_TAG" ]; then
IMAGE_SIZE_BYTES=$(docker image inspect "$IMAGE_TAG" --format='{{.Size}}' 2>/dev/null || echo "0")
echo "📦 Image size: ${IMAGE_SIZE_BYTES} bytes"
if [ "${{ inputs.no_load }}" == "false" ]; then
# Image was loaded into local Docker daemon but not pushed; docker inspect
# reports uncompressed (virtual) size, which differs from the compressed
# registry size reported below
IMAGE_SIZE_BYTES=$(docker image inspect "$IMAGE_TAG" --format='{{.Size}}' 2>/dev/null || echo "0")
IMAGE_SIZE_TYPE="uncompressed"
elif [ "${{ inputs.push_image }}" == "true" ]; then
# Image was pushed to ECR without loading locally; query ECR for compressed size
REPO_NAME=$(echo "$IMAGE_TAG" | sed 's|.*amazonaws.com/||' | cut -d: -f1)
IMAGE_TAG_NAME=$(echo "$IMAGE_TAG" | cut -d: -f2-)
IMAGE_SIZE_BYTES=$(aws ecr describe-images \
--repository-name "$REPO_NAME" \
--image-ids "imageTag=${IMAGE_TAG_NAME}" \
--query 'imageDetails[0].imageSizeInBytes' \
--output text 2>/dev/null || echo "0")
# Treat empty or "None" response as 0
if [[ "$IMAGE_SIZE_BYTES" == "None" || -z "$IMAGE_SIZE_BYTES" ]]; then
IMAGE_SIZE_BYTES=0
fi
IMAGE_SIZE_TYPE="compressed"
else
IMAGE_SIZE_BYTES=0
fi
echo "📦 Image size: ${IMAGE_SIZE_BYTES} bytes (${IMAGE_SIZE_TYPE})"
else
IMAGE_SIZE_BYTES=0
echo "⚠️ No image tag available"
......@@ -223,6 +248,7 @@ runs:
"platform": "${{ inputs.platform }}",
"platform_arch": "${PLATFORM_ARCH}",
"image_size_bytes": ${IMAGE_SIZE_BYTES},
"image_size_type": "${IMAGE_SIZE_TYPE}",
"build_start_time": "${BUILD_START_TIME}",
"build_end_time": "${BUILD_END_TIME}",
"build_duration_sec": ${BUILD_DURATION_SEC}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment