Skip to content

Commit

Permalink
Add recipe to calculate image size (#1088)
Browse files Browse the repository at this point in the history
* Add recipe to calculate image size

* document --platform for indexes
  • Loading branch information
imjasonh authored Jul 30, 2021
1 parent a3a06bb commit 4759a5d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/crane/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ diff <(crane config busybox:1.32 | jq) <(crane config busybox:1.33 | jq)
```
diff <(crane manifest busybox:1.32 | jq) <(crane manifest busybox:1.33 | jq)
```

### Get total image size

Given an image manifest, you can calculate the total size of all layer blobs and the image's config blob using `jq`:

```
crane manifest gcr.io/buildpacks/builder:v1 | jq '.config.size + ([.layers[].size] | add)'
```

This will produce a number of bytes, which you can make human-readable by passing to [`numfmt`](https://www.gnu.org/software/coreutils/manual/html_node/numfmt-invocation.html)

```
crane manifest gcr.io/buildpacks/builder:v1 | jq '.config.size + ([.layers[].size] | add)' | numfmt --to=iec
```

For image indexes, you can pass the `--platform` flag to `crane` to get a platform-specific image.

0 comments on commit 4759a5d

Please sign in to comment.