    def build(  # type: ignore (not accessed)
        build_ctx: str,
        bentofile: str | None,
        version: str | None,
        labels: tuple[str, ...],
        output: t.Literal["tag", "default"],
        push: bool,
        force: bool,
        threads: int,
        containerize: bool,
        platform: str | None,
    ):
        """Build a new Bento from current directory."""
        from bentoml._internal.configuration import set_quiet_mode
        from bentoml._internal.log import configure_logging

        if output == "tag":
            set_quiet_mode()
            configure_logging()

        labels_dict: dict[str, t.Any] = {}
        for label in labels:
            key, label_value = label.split("=", 1)
            labels_dict[key] = label_value

        service: str | None = None
        if ":" in build_ctx:
            service = build_ctx
            build_ctx = "."

        bento = build_bentofile(
            bentofile,
            service=service,
            version=version,
            labels=labels_dict or None,
            build_ctx=build_ctx,
            platform=platform,
        )

        containerize_cmd = f"bentoml containerize {bento.tag}"
        push_cmd = f"bentoml push {bento.tag}"

        # NOTE: Don't remove the return statement here, since we will need this
        # for usage stats collection if users are opt-in.
        if output == "tag":
            rich.print(f"__tag__:{bento.tag}")
        else:
            if not get_quiet_mode():
                rich.print(BENTOML_FIGLET)
                rich.print(f"[green]Successfully built {bento}.")
                next_steps = [
                    f"\n\n* Deploy to BentoCloud:\n    $ bentoml deploy {bento.tag} -n ${{DEPLOYMENT_NAME}}",
                    "\n\n* Update an existing deployment on BentoCloud:\n"
                    f"    $ bentoml deployment update --bento {bento.tag} ${{DEPLOYMENT_NAME}}",
                ]
                if not containerize:
                    next_steps.append(
                        "\n\n* Containerize your Bento with `bentoml containerize`:\n"
                        f"    $ {containerize_cmd} [or bentoml build --containerize]"
                    )
                if not push:
                    next_steps.append(
                        "\n\n* Push to BentoCloud with `bentoml push`:\n"
                        f"    $ {push_cmd} [or bentoml build --push]"
                    )

                if next_steps:
                    rich.print(f"\n[blue]Next steps: {''.join(next_steps)}[/]")
        if push:
            if not get_quiet_mode():
                rich.print(f"\n[magenta]Pushing {bento} to BentoCloud...[/]")
            cloud_client = BentoMLContainer.bentocloud_client.get()
            cloud_client.bento.push(bento, force=force, threads=threads)
        elif containerize:
            backend: DefaultBuilder = t.cast(
                "DefaultBuilder", os.getenv("BENTOML_CONTAINERIZE_BACKEND", "docker")
            )
            try:
                bentoml.container.health(backend)
            except subprocess.CalledProcessError:
                raise bentoml.exceptions.BentoMLException(
                    f"Backend {backend} is not healthy"
                )
            bentoml.container.build(bento.tag, backend=backend)

        return bento
Build a new Bento from current directory.
src/bentoml_cli/bentos.py