-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgenerate-benchmark.sh
executable file
·33 lines (29 loc) · 1.59 KB
/
generate-benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# shellcheck shell=bash
set -euo pipefail
# Fetches images, extracts daemon version and container size
# TODO Benchmark should be run as part of release engineering/automation
declare -A images=(
["mysql"]="library/mysql"
["mariadb"]="library/mariadb"
["bitnami/mariadb"]="bitnami/mariadb"
["linuxserver/mariadb"]="linuxserver/mariadb"
["clearlinux/mariadb"]="clearlinux/mariadb"
["**jbergstroem/mariadb-alpine**"]="jbergstroem/mariadb-alpine"
)
for image in "${!images[@]}"; do
entrypoint=mariadbd
[[ "${image}" == "mysql" ]] && entrypoint="mysqld"
docker pull -q "${images[$image]}:latest" >/dev/null 2>&1
version=$(docker run -it --rm --entrypoint "${entrypoint}" "${images[$image]}:latest" --version)
[[ "${version}" =~ Ver[[:space:]]([0-9]+.[0-9]+.[0-9]+) ]]
parsed_version="${BASH_REMATCH[1]}"
compressed_size=$(curl -L -s "https://hub.docker.com/v2/repositories/${images[${image}]}/tags?page_size=100" | jq '.results[] | select(.name =="latest") | .full_size' | numfmt --from=iec --to=iec-i --format "%.1f")
size=$(docker image inspect -f "{{.Size}}" "${images[$image]}" | numfmt --from=iec --to=iec-i --format "%.1f")
output+=("| ${image} | ${compressed_size} (${size}) | [${parsed_version}](https://hub.docker.com/layers/${images[$image]}/latest/images/latest?context=explore) |")
# some images may already exist on disk and be in use, we don't care if pruning fails
docker rmi "${images[$image]}" >/dev/null 2>&1 || true
done
echo "| Image name | Compressed size (Original) | Version |"
echo "|:--|:--|:--|"
printf "%s\n" "${output[@]}" | sort -t '|' -k 3 -h