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.
This commit is contained in:
2025-09-25 16:40:20 -06:00
parent b9cffe3008
commit be171cf2c6

View File

@@ -622,6 +622,9 @@ def build_image(
push: bool = typer.Option( push: bool = typer.Option(
False, "--push", "-p", help="Push image to registry after building" False, "--push", "-p", help="Push image to registry after building"
), ),
no_cache: bool = typer.Option(
False, "--no-cache", help="Build without using cache"
),
) -> None: ) -> None:
"""Build an image Docker image""" """Build an image Docker image"""
# Get image path # Get image path
@@ -686,9 +689,11 @@ def build_image(
# Build the image from temporary directory # Build the image from temporary directory
with console.status(f"Building image {docker_image_name}..."): with console.status(f"Building image {docker_image_name}..."):
result = os.system( build_cmd = f"cd {temp_path} && docker build"
f"cd {temp_path} && docker build -t {docker_image_name} ." if no_cache:
) build_cmd += " --no-cache"
build_cmd += f" -t {docker_image_name} ."
result = os.system(build_cmd)
except Exception as e: except Exception as e:
console.print(f"[red]Error preparing build context: {e}[/red]") console.print(f"[red]Error preparing build context: {e}[/red]")