Source code for gyoza.cli.commands.build

"""Build command for the gyoza CLI."""

from __future__ import annotations

import subprocess
from pathlib import Path

import typer

from gyoza.cli.errors import fail

_SEPARATOR = "━" * 50


[docs] def build( path: str = typer.Argument( ..., help="Path to the project directory containing gyoza.yml.", ), ) -> None: """Build the Docker image defined in gyoza.yml.""" project_path = Path(path).resolve() if not project_path.is_dir(): fail(f"Not a directory: {project_path}") typer.echo(f"\n{_SEPARATOR}") typer.echo(" 🔨 GYOZA BUILD") typer.echo(f"{_SEPARATOR}\n") typer.echo(f" 📂 Project: {project_path}") typer.echo(" 🐳 Building Docker image...\n") try: from gyoza.deployment import build as run_build run_build(project_path) typer.echo(f"\n{_SEPARATOR}") typer.echo(" ✅ Build completed successfully!") typer.echo(f"{_SEPARATOR}\n") except FileNotFoundError as exc: fail(str(exc)) except ValueError as exc: fail(str(exc)) except subprocess.CalledProcessError as exc: fail(f"docker build failed (exit code {exc.returncode})")