Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure final docker image size #893

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/_build_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/docker_size.sh
dockersize ${{ steps.meta.outputs.tags }}

- name: Generate sitrep
if: "!cancelled()"
shell: bash -x -e {0}
Expand Down
39 changes: 5 additions & 34 deletions .github/workflows/_sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,9 @@ 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
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
15 changes: 15 additions & 0 deletions .github/workflows/scripts/docker_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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(" ")' \
| numfmt --to iec --format '%.2f' --field 2 | column -t ;
}
Loading