Rebuild images every 24hrs

This commit is contained in:
Tom Wilkie
2015-08-17 15:21:33 +00:00
parent 6b74be05cd
commit d6044b2c13

View File

@@ -33,6 +33,11 @@ has_changes() {
[ "$changes" -gt 0 ]
}
commit_timestamp() {
local rev=$1
git show -s --format=%ct $rev
}
cached_revision=$(cached_image_rev)
if [ -z "$cached_revision" ]; then
echo ">>> No cached image found; rebuilding"
@@ -47,6 +52,12 @@ if has_changes $cached_revision $CIRCLE_SHA1 ; then
exit 0
fi
if [ "$(commit_timestamp $cached_revision)" -lt "$(( $(date +%s) - 86400 ))" ]; then
echo ">>> Image is more the 24hrs old; rebuilding"
rebuild
exit 0
fi
# we didn't rebuild; import cached version
echo ">>> No changes found, importing cached image"
docker load -i $CACHEDIR/$SAVEDNAME-$cached_revision