aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2023-10-14 15:56:24 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2023-10-14 15:56:24 -0500
commitb314c984a9e34c766340b451efa53f39f0f845f7 (patch)
treed3c91aa2f59f2b0de03c6de75d80b240e0a195a8
parent71b0e296f725baf501b4af81cf82dd1aad428003 (diff)
downloadrbuild-b314c984a9e34c766340b451efa53f39f0f845f7.tar.xz
rbuild-b314c984a9e34c766340b451efa53f39f0f845f7.zip
Add option to prune the image build cacheHEADmain
-rw-r--r--rbuild.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/rbuild.py b/rbuild.py
index 6ba7a79..42a8723 100644
--- a/rbuild.py
+++ b/rbuild.py
@@ -169,6 +169,7 @@ if __name__ == '__main__':
parser.add_argument('--build-period', type=int, default=BUILD_TTL, help='Time images are allowed to live (in seconds.)')
parser.add_argument('--up-timeout-period', type=int, default=UP_TIMEOUT_PERIOD, help='Up timeout period in seconds.')
parser.add_argument('--force-rebuild', default=False, action='store_true', help='Force all containers to be rebuilt')
+ parser.add_argument('--prune-image-cache', default=False, action='store_true', help='Prune the global image cache')
# Add remove-images to the mutually exclusive group
parser.add_argument('--remove-images', default=False, action='store_true', help='Remove all images')
@@ -190,5 +191,18 @@ if __name__ == '__main__':
if args.remove_images:
remove_main(filename)
- build_main(filename, force_rebuild=args.force_rebuild)
+ build_main(
+ filename,
+ force_rebuild=args.force_rebuild,
+ )
+
+ # Prune the image build cache if requested. The image build cache can gobble
+ # up system disk space. A better implementation may create an isolated
+ # buildkit instance, ideally providing rbuild a separate cache. The
+ # documentation for buildkit instances are fairly sparse and I may add this
+ # in the future.
+ if args.prune_image_cache:
+ subprocess.run([
+ "docker", "buildx", "prune", "--force"
+ ], check=True)