Skip to content

Commit

Permalink
Prune build cache to 10Gb after creating images
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart X Addison <[email protected]>
  • Loading branch information
sxa committed Apr 26, 2023
1 parent cf9a794 commit ac2c83a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pipeline {
def dockerBuild(version) {
// dockerhub is the ID of the credentials stored in Jenkins
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') {
git poll: false, url: 'https://github.com/AdoptOpenJDK/openjdk-docker.git'
git poll: false, url: 'https://github.com/sxa/openjdk-docker.git', branch: 'purge_cache'
if (version){
sh label: '', script: "./build_all.sh ${version}"
} else {
Expand Down
1 change: 1 addition & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ remove_summary_table_file
# Cleanup any old containers and images
cleanup_images
cleanup_manifest
clear_build_cache
13 changes: 13 additions & 0 deletions common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ function cleanup_manifest() {
rm -rf ~/.docker/manifests
}

function clear_build_cache() {
# Reduce the size of the build cache to avoid exhaustion of the space
docker system df
echo Pruning builder cache to 10Gb
# docker on our arm32 machines gives parse error if bigger than this
if [ "$(uname -m)" = "armv7l" ]; then
SPACE_TO_KEEP=2100000000
else
SPACE_TO_KEEP=10000000000
fi
docker builder prune -f --keep-storage ${SPACE_TO_KEEP}
}

# Check if a given docker image exists on the server.
# This script errors out if the image does not exist.
function check_image() {
Expand Down

0 comments on commit ac2c83a

Please sign in to comment.