diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2023-10-14 15:56:24 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2023-10-14 15:56:24 -0500 |
| commit | 1785b32e807c2fe97ddf0f8f0f0fa02ca524ed2b (patch) | |
| tree | d3c91aa2f59f2b0de03c6de75d80b240e0a195a8 /rbuild.py | |
| parent | 9e252bbf56147d31c5a3c15fe09a7773b7060d7f (diff) | |
Diffstat (limited to 'rbuild.py')
| -rw-r--r-- | rbuild.py | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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) |
