From be171cf2c6252dfa926a759915a057a3a6791cc2 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 25 Sep 2025 16:40:20 -0600 Subject: [PATCH] feat: add --no-cache option to image build command Added a --no-cache flag to 'cubbi image build' command to allow building Docker images without using the build cache, useful for forcing fresh builds. --- cubbi/cli.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cubbi/cli.py b/cubbi/cli.py index eb25a90..959f232 100644 --- a/cubbi/cli.py +++ b/cubbi/cli.py @@ -622,6 +622,9 @@ def build_image( push: bool = typer.Option( False, "--push", "-p", help="Push image to registry after building" ), + no_cache: bool = typer.Option( + False, "--no-cache", help="Build without using cache" + ), ) -> None: """Build an image Docker image""" # Get image path @@ -686,9 +689,11 @@ def build_image( # Build the image from temporary directory with console.status(f"Building image {docker_image_name}..."): - result = os.system( - f"cd {temp_path} && docker build -t {docker_image_name} ." - ) + build_cmd = f"cd {temp_path} && docker build" + if no_cache: + build_cmd += " --no-cache" + build_cmd += f" -t {docker_image_name} ." + result = os.system(build_cmd) except Exception as e: console.print(f"[red]Error preparing build context: {e}[/red]")