Source code for gyoza.cli.commands.deploy
"""Deploy 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 deploy(
path: str = typer.Argument(
...,
help="Path to the project directory containing gyoza.yml.",
),
) -> None:
"""Build, push, and register a gyoza operation on the gyoza server."""
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 DEPLOY")
typer.echo(f"{_SEPARATOR}\n")
typer.echo(f" 📂 Project: {project_path}\n")
try:
from gyoza.deployment import deploy as run_deploy
run_deploy(project_path, on_step=lambda msg: typer.echo(f" {msg}"))
typer.echo(f"\n{_SEPARATOR}")
typer.echo(" ✨ Done!")
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 command failed (exit code {exc.returncode})")
except Exception as exc: # noqa: BLE001
fail(f"Deploy failed: {exc}")