Created
October 26, 2024 18:02
-
-
Save avtar/bc97382db0d7c4da5ca647b1bb8e64f4 to your computer and use it in GitHub Desktop.
Report average docker build time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
total_time=0 | |
for i in 1 2 3 | |
do | |
echo "==> Cleaning up Docker environment before build #$i..." | |
docker system prune --all --volumes --force > /dev/null 2>&1 | |
echo "==> Running build #$i..." | |
start_time=$(date +%s) | |
docker build --platform linux/amd64 . > /dev/null 2>&1 | |
end_time=$(date +%s) | |
elapsed_time=$((end_time - start_time)) | |
echo "==> Time taken for build #$i: ${elapsed_time}s" | |
total_time=$((total_time + elapsed_time)) | |
done | |
average_time=$((total_time / 3)) | |
git_hash=$(git log -n 1 --pretty=format:"%h" -- Dockerfile) | |
echo "" | |
echo "==> Dockerfile $git_hash average build time: ${average_time}s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment