mirror of
https://github.com/Monadical-SAS/cubbi.git
synced 2025-12-20 12:19:07 +00:00
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:
11
cubbi/cli.py
11
cubbi/cli.py
@@ -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]")
|
||||||
|
|||||||
Reference in New Issue
Block a user