From 1d84cc345647b527d1e4fa99a0cc91eaeaea8446 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Mon, 10 Jun 2024 16:04:29 -0700 Subject: [PATCH 1/5] Add measurement for docker final container size(compressed) --- .github/workflows/_build.yaml | 6 ++++++ .github/workflows/_build_base.yaml | 8 +++++++- .github/workflows/scripts/docker_image_size.sh | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/scripts/docker_image_size.sh diff --git a/.github/workflows/_build.yaml b/.github/workflows/_build.yaml index 77d1f6469..277e91e2f 100644 --- a/.github/workflows/_build.yaml +++ b/.github/workflows/_build.yaml @@ -174,6 +174,12 @@ jobs: BUILD_DATE=${{ inputs.BUILD_DATE }} ${{ inputs.EXTRA_BUILD_ARGS }} + - name: Docker image compressed size + shell: bash -x -e {0} + run: | + . .github/workflows/scripts/compressed_image_size.sh + compressed_docker_size ${{ steps.final-metadata.outputs.tags }} + - name: Generate sitrep if: "!cancelled()" shell: bash -x -e {0} diff --git a/.github/workflows/_build_base.yaml b/.github/workflows/_build_base.yaml index b575ec14b..7643f6b5b 100644 --- a/.github/workflows/_build_base.yaml +++ b/.github/workflows/_build_base.yaml @@ -133,7 +133,13 @@ jobs: GIT_USER_EMAIL=${{ inputs.GIT_USER_EMAIL }} BUILD_DATE=${{ inputs.BUILD_DATE }} ${{ inputs.BASE_IMAGE != 'latest' && format('BASE_IMAGE={0}', inputs.BASE_IMAGE) || '' }} - + + - name: Docker image compressed size + shell: bash -x -e {0} + run: | + . .github/workflows/scripts/compressed_image_size.sh + compressed_docker_size ${{ steps.meta.outputs.tags }} + - name: Generate sitrep if: "!cancelled()" shell: bash -x -e {0} diff --git a/.github/workflows/scripts/docker_image_size.sh b/.github/workflows/scripts/docker_image_size.sh new file mode 100644 index 000000000..594467de8 --- /dev/null +++ b/.github/workflows/scripts/docker_image_size.sh @@ -0,0 +1,6 @@ +function compressed_docker_size() { + docker manifest inspect -v "$1" \ + | jq -c 'if type == "array" then .[] else . end' \ + | jq -r '[ ( .Descriptor.platform | [ .os, .architecture, .variant, ."os.version" ] | del(..|nulls) | join("/") ), ( [ .SchemaV2Manifest.layers[].size ] | add ) ] | join(" ")' \ + | numfmt --to iec --format '%.2f' --field 2 | column -t ; +} From 17a09aa51de0c05519336fb74d759f299d6cfa80 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Mon, 10 Jun 2024 16:10:32 -0700 Subject: [PATCH 2/5] Add measurement for docker final container size(compressed) --- .github/workflows/_sandbox.yaml | 41 ++++++--------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/.github/workflows/_sandbox.yaml b/.github/workflows/_sandbox.yaml index 7b90b72ca..0525da32d 100644 --- a/.github/workflows/_sandbox.yaml +++ b/.github/workflows/_sandbox.yaml @@ -4,38 +4,11 @@ on: workflow_dispatch: jobs: - sandbox: - runs-on: ubuntu-22.04 - steps: - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + build-base: + uses: ./.github/workflows/_build_base.yaml + with: + ARCHITECTURE: amd64 + BUILD_DATE: "2024-14-25" + MANIFEST_ARTIFACT_NAME: base + secrets: inherit - - name: Print usage - run: | - cat << EOF - This is an empty workflow file located in the main branch of your - repository. It serves as a testing ground for new GitHub Actions on - development branches before merging them to the main branch. By - defining and overloading this workflow on your development branch, - you can test new actions without affecting your main branch, ensuring - a smooth integration process once the changes are ready to be merged. - - Usage: - - 1. In your development branch, modify the sandbox.yml workflow file - to include the new actions you want to test. Make sure to commit - the changes to the development branch. - 2. Navigate to the 'Actions' tab in your repository, select the - '~Sandbox' workflow, and choose your development branch from the - branch dropdown menu. Click on 'Run workflow' to trigger the - workflow on your development branch. - 3. Once you have tested and verified the new actions in the Sandbox - workflow, you can incorporate them into your main workflow(s) and - merge the development branch into the main branch. Remember to - revert the changes to the sandbox.yml file in the main branch to - keep it empty for future testing. - EOF From 149a8b83c3b6820800e42348ee515ee4303033c2 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Mon, 10 Jun 2024 16:13:37 -0700 Subject: [PATCH 3/5] Run sandbox --- .github/workflows/_sandbox.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/_sandbox.yaml b/.github/workflows/_sandbox.yaml index 0525da32d..309b9a695 100644 --- a/.github/workflows/_sandbox.yaml +++ b/.github/workflows/_sandbox.yaml @@ -8,7 +8,5 @@ jobs: uses: ./.github/workflows/_build_base.yaml with: ARCHITECTURE: amd64 - BUILD_DATE: "2024-14-25" - MANIFEST_ARTIFACT_NAME: base secrets: inherit From 1ff02fa09d196f6de9a8ba7514924a37f93819b5 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Mon, 10 Jun 2024 16:31:48 -0700 Subject: [PATCH 4/5] Run sandbox --- .github/workflows/_build_base.yaml | 4 ++-- .../scripts/{docker_image_size.sh => docker_size.sh} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/scripts/{docker_image_size.sh => docker_size.sh} (90%) diff --git a/.github/workflows/_build_base.yaml b/.github/workflows/_build_base.yaml index 7643f6b5b..828ccf9de 100644 --- a/.github/workflows/_build_base.yaml +++ b/.github/workflows/_build_base.yaml @@ -137,8 +137,8 @@ jobs: - name: Docker image compressed size shell: bash -x -e {0} run: | - . .github/workflows/scripts/compressed_image_size.sh - compressed_docker_size ${{ steps.meta.outputs.tags }} + . .github/workflows/scripts/docker_size.sh + dockersize ${{ steps.meta.outputs.tags }} - name: Generate sitrep if: "!cancelled()" diff --git a/.github/workflows/scripts/docker_image_size.sh b/.github/workflows/scripts/docker_size.sh similarity index 90% rename from .github/workflows/scripts/docker_image_size.sh rename to .github/workflows/scripts/docker_size.sh index 594467de8..bed039949 100644 --- a/.github/workflows/scripts/docker_image_size.sh +++ b/.github/workflows/scripts/docker_size.sh @@ -1,4 +1,4 @@ -function compressed_docker_size() { +function dockersize() { docker manifest inspect -v "$1" \ | jq -c 'if type == "array" then .[] else . end' \ | jq -r '[ ( .Descriptor.platform | [ .os, .architecture, .variant, ."os.version" ] | del(..|nulls) | join("/") ), ( [ .SchemaV2Manifest.layers[].size ] | add ) ] | join(" ")' \ From 19cc606658dfcefa60de10a8387d1dc7b9f41690 Mon Sep 17 00:00:00 2001 From: Vladislav Date: Mon, 10 Jun 2024 21:19:19 -0700 Subject: [PATCH 5/5] Run sandbox with debugging --- .github/workflows/scripts/docker_size.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/scripts/docker_size.sh b/.github/workflows/scripts/docker_size.sh index bed039949..448a3890b 100644 --- a/.github/workflows/scripts/docker_size.sh +++ b/.github/workflows/scripts/docker_size.sh @@ -1,4 +1,13 @@ function dockersize() { + docker manifest inspect -v "$1" + echo "**************************" + docker manifest inspect -v "$1" \ + | jq -c 'if type == "array" then .[] else . end' + echo "**************************" + docker manifest inspect -v "$1" \ + | jq -c 'if type == "array" then .[] else . end' \ + | jq -r '[ ( .Descriptor.platform | [ .os, .architecture, .variant, ."os.version" ] | del(..|nulls) | join("/") ), ( [ .SchemaV2Manifest.layers[].size ] | add ) ] | join(" ")' + echo "**************************" docker manifest inspect -v "$1" \ | jq -c 'if type == "array" then .[] else . end' \ | jq -r '[ ( .Descriptor.platform | [ .os, .architecture, .variant, ."os.version" ] | del(..|nulls) | join("/") ), ( [ .SchemaV2Manifest.layers[].size ] | add ) ] | join(" ")' \