Skip to content

Commit 4759a5d

Browse files
authored
Add recipe to calculate image size (#1088)
* Add recipe to calculate image size * document --platform for indexes
1 parent a3a06bb commit 4759a5d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: cmd/crane/recipes.md

+16
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,19 @@ diff <(crane config busybox:1.32 | jq) <(crane config busybox:1.33 | jq)
5151
```
5252
diff <(crane manifest busybox:1.32 | jq) <(crane manifest busybox:1.33 | jq)
5353
```
54+
55+
### Get total image size
56+
57+
Given an image manifest, you can calculate the total size of all layer blobs and the image's config blob using `jq`:
58+
59+
```
60+
crane manifest gcr.io/buildpacks/builder:v1 | jq '.config.size + ([.layers[].size] | add)'
61+
```
62+
63+
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)
64+
65+
```
66+
crane manifest gcr.io/buildpacks/builder:v1 | jq '.config.size + ([.layers[].size] | add)' | numfmt --to=iec
67+
```
68+
69+
For image indexes, you can pass the `--platform` flag to `crane` to get a platform-specific image.

0 commit comments

Comments
 (0)