def generate_containerfile(
    docker: DockerOptions,
    build_ctx: str,
    *,
    conda: CondaOptions,
    bento_fs: FS,
    frontend: str = "dockerfile",
    **override_bento_env: t.Any,
) -> str:
    """
    Generate a Dockerfile that containerize a Bento.

    .. note::

        You should use ``construct_containerfile`` instead of this function.

    Returns:
        str: The rendered Dockerfile string.

    .. dropdown:: Implementation Notes

        The coresponding Dockerfile template will be determined automatically based on given :class:`DockerOptions`.
        The templates are located `here <https://github.com/bentoml/BentoML/tree/main/src/bentoml/_internal/bento/docker/templates>`_

        As one can see, the Dockerfile templates are organized with the format :code:`<release_type>_<distro>.j2` with:

        +---------------+------------------------------------------+
        | Release type  | Description                              |
        +===============+==========================================+
        | base          | A base setup for all supported distros.  |
        +---------------+------------------------------------------+
        | cuda          | CUDA-supported templates.                |
        +---------------+------------------------------------------+
        | miniconda     | Conda-supported templates.               |
        +---------------+------------------------------------------+
        | python        | Python releases.                         |
        +---------------+------------------------------------------+

        All templates will have the following blocks: "SETUP_BENTO_BASE_IMAGE", "SETUP_BENTO_USER", "SETUP_BENTO_ENVARS", "SETUP_BENTO_COMPONENTS", "SETUP_BENTO_ENTRYPOINT",

        Overriding templates variables: bento__uid_gid, bento__user, bento__home, bento__path, bento__enable_buildkit
    """
    TEMPLATES_PATH = [
        os.path.join(os.path.dirname(__file__), "frontend", frontend, "templates")
    ]
    ENVIRONMENT = Environment(
        extensions=["jinja2.ext.do", "jinja2.ext.loopcontrols", "jinja2.ext.debug"],
        trim_blocks=True,
        lstrip_blocks=True,
        loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True),
    )
    ENVIRONMENT.filters["bash_quote"] = shlex.quote

    if docker.cuda_version is not None:
        release_type = "cuda"
    elif not conda.is_empty():
        release_type = "miniconda"
    else:
        release_type = "python"
    base = f"{release_type}_{docker.distro}.j2"
    if docker.base_image is not None:
        # If base_image is specified, then use the base template instead.
        base = "base.j2"

    template = ENVIRONMENT.get_template(base, globals=J2_FUNCTION)
    logger.debug(
        'Using base Dockerfile template: "%s" (path: "%s")',
        base,
        os.path.join(TEMPLATES_PATH[0], base),
    )

    user_templates = docker.dockerfile_template
    if user_templates is not None:
        dir_path = os.path.dirname(resolve_user_filepath(user_templates, build_ctx))
        user_templates = os.path.basename(user_templates)
        TEMPLATES_PATH.append(dir_path)
        environment = ENVIRONMENT.overlay(
            loader=FileSystemLoader(TEMPLATES_PATH, followlinks=True)
        )
        template = environment.get_template(
            user_templates,
            globals={"bento_base_template": template, **J2_FUNCTION},
        )

    requirement_file = bento_fs.getsyspath("env/python/requirements.lock.txt")
    if not os.path.exists(requirement_file):
        requirement_file = bento_fs.getsyspath("env/python/requirements.txt")
    if os.path.exists(requirement_file):
        python_packages = resolve_package_versions(requirement_file)
    else:
        python_packages = {}

    return template.render(
        **get_templates_variables(
            docker,
            conda,
            bento_fs,
            python_packages=python_packages,
            _is_cuda=release_type == "cuda",
            **override_bento_env,
        )
    )
Generate a Dockerfile that containerize a Bento.

.. note::

You should use ``construct_containerfile`` instead of this function.

Returns:
str: The rendered Dockerfile string.

.. dropdown:: Implementation Notes

The coresponding Dockerfile template will be determined automatically based on given :class:`DockerOptions`.
The templates are located `here <https://github.com/bentoml/BentoML/tree/main/src/bentoml/_internal/bento/docker/templates>`_

As one can see, the Dockerfile templates are organized with the format :code:`<release_type>_<distro>.j2` with:

+---------------+------------------------------------------+
| Release type  | Description                              |
+===============+==========================================+
| base          | A base setup for all supported distros.  |
+---------------+------------------------------------------+
| cuda          | CUDA-supported templates.                |
+---------------+------------------------------------------+
| miniconda     | Conda-supported templates.               |
+---------------+------------------------------------------+
| python        | Python releases.                         |
+---------------+------------------------------------------+

All templates will have the following blocks: "SETUP_BENTO_BASE_IMAGE", "SETUP_BENTO_USER", "SETUP_BENTO_ENVARS", "SETUP_BENTO_COMPONENTS", "SETUP_BENTO_ENTRYPOINT",

Overriding templates variables: bento__uid_gid, bento__user, bento__home, bento__path, bento__enable_buildkit
src/bentoml/_internal/container/generate.py