prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add docker build option to not use cache
  To ensure fresh environment and while potentially developing a new model version users will not want to use cached layers in the docker build for their image.
  
  In docker this is the --no-cache option, I would make it a boolean option within the cli and also add the --rm option (although default is true might be worth making sure) to remove any intermediate containers after success to again ensure a clean environment in CI/CD as well as locally. 
  
  </issue>
  <code>
  [start of mlserver/cli/build.py]
  1 import subprocess
  2 import os
  3 
  4 from tempfile import TemporaryDirectory
  5 
  6 from .. import __version__
  7 from ..logging import logger
  8 
  9 from .constants import (
  10     DockerfileName,
  11     DockerfileTemplate,
  12     DockerignoreName,
  13     Dockerignore,
  14 )
  15 
  16 
  17 def generate_dockerfile() -> str:
  18     return DockerfileTemplate.format(version=__version__)
  19 
  20 
  21 def write_dockerfile(
  22     folder: str, dockerfile: str, include_dockerignore: bool = True
  23 ) -> str:
  24     dockerfile_path = os.path.join(folder, DockerfileName)
  25     with open(dockerfile_path, "w") as dockerfile_handler:
  26         logger.info(f"Writing Dockerfile in {dockerfile_path}")
  27         dockerfile_handler.write(dockerfile)
  28 
  29     if include_dockerignore:
  30         # Point to our own .dockerignore
  31         # https://docs.docker.com/engine/reference/commandline/build/#use-a-dockerignore-file
  32         dockerignore_path = dockerfile_path + DockerignoreName
  33         with open(dockerignore_path, "w") as dockerignore_handler:
  34             logger.info(f"Writing .dockerignore in {dockerignore_path}")
  35             dockerignore_handler.write(Dockerignore)
  36 
  37     return dockerfile_path
  38 
  39 
  40 def build_image(folder: str, dockerfile: str, image_tag: str) -> str:
  41     logger.info(f"Building Docker image with tag {image_tag}")
  42     with TemporaryDirectory() as tmp_dir:
  43         dockerfile_path = write_dockerfile(tmp_dir, dockerfile)
  44 
  45         build_cmd = f"docker build {folder} -f {dockerfile_path} -t {image_tag}"
  46         build_env = os.environ.copy()
  47         build_env["DOCKER_BUILDKIT"] = "1"
  48         subprocess.run(build_cmd, check=True, shell=True, env=build_env)
  49 
  50     return image_tag
  51
  [end of mlserver/cli/build.py]
  [start of mlserver/cli/main.py]
  1 """
  2 Command-line interface to manage MLServer models.
  3 """
  4 import click
  5 import asyncio
  6 
  7 from functools import wraps
  8 
  9 from ..server import MLServer
  10 from ..logging import logger, configure_logger
  11 from ..utils import install_uvloop_event_loop
  12 
  13 from .build import generate_dockerfile, build_image, write_dockerfile
  14 from .serve import load_settings
  15 
  16 
  17 def click_async(f):
  18     @wraps(f)
  19     def wrapper(*args, **kwargs):
  20         return asyncio.run(f(*args, **kwargs))
  21 
  22     return wrapper
  23 
  24 
  25 @click.group()
  26 @click.version_option()
  27 def root():
  28     """
  29     Command-line interface to manage MLServer models.
  30     """
  31     pass
  32 
  33 
  34 @root.command("start")
  35 @click.argument("folder", nargs=1)
  36 @click_async
  37 async def start(folder: str):
  38     """
  39     Start serving a machine learning model with MLServer.
  40     """
  41     settings, models_settings = await load_settings(folder)
  42 
  43     server = MLServer(settings)
  44     await server.start(models_settings)
  45 
  46 
  47 @root.command("build")
  48 @click.argument("folder", nargs=1)
  49 @click.option("-t", "--tag", type=str)
  50 @click_async
  51 async def build(folder: str, tag: str):
  52     """
  53     Build a Docker image for a custom MLServer runtime.
  54     """
  55     dockerfile = generate_dockerfile()
  56     build_image(folder, dockerfile, tag)
  57     logger.info(f"Successfully built custom Docker image with tag {tag}")
  58 
  59 
  60 @root.command("dockerfile")
  61 @click.argument("folder", nargs=1)
  62 @click.option("-i", "--include-dockerignore", is_flag=True)
  63 @click_async
  64 async def dockerfile(folder: str, include_dockerignore: bool):
  65     """
  66     Generate a Dockerfile
  67     """
  68     dockerfile = generate_dockerfile()
  69     dockerfile_path = write_dockerfile(
  70         folder, dockerfile, include_dockerignore=include_dockerignore
  71     )
  72     logger.info(f"Successfully written Dockerfile in {dockerfile_path}")
  73 
  74 
  75 def main():
  76     configure_logger()
  77     install_uvloop_event_loop()
  78     root()
  79 
  80 
  81 if __name__ == "__main__":
  82     main()
  83
  [end of mlserver/cli/main.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mlserver/cli/build.py b/mlserver/cli/build.py
  --- a/mlserver/cli/build.py
  +++ b/mlserver/cli/build.py
  @@ -37,12 +37,18 @@
       return dockerfile_path
   
   
  -def build_image(folder: str, dockerfile: str, image_tag: str) -> str:
  +def build_image(
  +    folder: str, dockerfile: str, image_tag: str, no_cache: bool = False
  +) -> str:
       logger.info(f"Building Docker image with tag {image_tag}")
  +    _docker_command_prefix = "docker build --rm "
       with TemporaryDirectory() as tmp_dir:
           dockerfile_path = write_dockerfile(tmp_dir, dockerfile)
  -
  -        build_cmd = f"docker build {folder} -f {dockerfile_path} -t {image_tag}"
  +        _docker_command_suffix = f"{folder} -f {dockerfile_path} -t {image_tag}"
  +        if no_cache:
  +            build_cmd = _docker_command_prefix + "--no-cache " + _docker_command_suffix
  +        else:
  +            build_cmd = _docker_command_prefix + _docker_command_suffix
           build_env = os.environ.copy()
           build_env["DOCKER_BUILDKIT"] = "1"
           subprocess.run(build_cmd, check=True, shell=True, env=build_env)
  diff --git a/mlserver/cli/main.py b/mlserver/cli/main.py
  --- a/mlserver/cli/main.py
  +++ b/mlserver/cli/main.py
  @@ -47,13 +47,14 @@
   @root.command("build")
   @click.argument("folder", nargs=1)
   @click.option("-t", "--tag", type=str)
  +@click.option("--no-cache", default=False, is_flag=True)
   @click_async
  -async def build(folder: str, tag: str):
  +async def build(folder: str, tag: str, no_cache: bool = False):
       """
       Build a Docker image for a custom MLServer runtime.
       """
       dockerfile = generate_dockerfile()
  -    build_image(folder, dockerfile, tag)
  +    build_image(folder, dockerfile, tag, no_cache=no_cache)
       logger.info(f"Successfully built custom Docker image with tag {tag}")
  
verification_info: {"golden_diff": "diff --git a/mlserver/cli/build.py b/mlserver/cli/build.py\n--- a/mlserver/cli/build.py\n+++ b/mlserver/cli/build.py\n@@ -37,12 +37,18 @@\n     return dockerfile_path\n \n \n-def build_image(folder: str, dockerfile: str, image_tag: str) -> str:\n+def build_image(\n+    folder: str, dockerfile: str, image_tag: str, no_cache: bool = False\n+) -> str:\n     logger.info(f\"Building Docker image with tag {image_tag}\")\n+    _docker_command_prefix = \"docker build --rm \"\n     with TemporaryDirectory() as tmp_dir:\n         dockerfile_path = write_dockerfile(tmp_dir, dockerfile)\n-\n-        build_cmd = f\"docker build {folder} -f {dockerfile_path} -t {image_tag}\"\n+        _docker_command_suffix = f\"{folder} -f {dockerfile_path} -t {image_tag}\"\n+        if no_cache:\n+            build_cmd = _docker_command_prefix + \"--no-cache \" + _docker_command_suffix\n+        else:\n+            build_cmd = _docker_command_prefix + _docker_command_suffix\n         build_env = os.environ.copy()\n         build_env[\"DOCKER_BUILDKIT\"] = \"1\"\n         subprocess.run(build_cmd, check=True, shell=True, env=build_env)\ndiff --git a/mlserver/cli/main.py b/mlserver/cli/main.py\n--- a/mlserver/cli/main.py\n+++ b/mlserver/cli/main.py\n@@ -47,13 +47,14 @@\n @root.command(\"build\")\n @click.argument(\"folder\", nargs=1)\n @click.option(\"-t\", \"--tag\", type=str)\n+@click.option(\"--no-cache\", default=False, is_flag=True)\n @click_async\n-async def build(folder: str, tag: str):\n+async def build(folder: str, tag: str, no_cache: bool = False):\n     \"\"\"\n     Build a Docker image for a custom MLServer runtime.\n     \"\"\"\n     dockerfile = generate_dockerfile()\n-    build_image(folder, dockerfile, tag)\n+    build_image(folder, dockerfile, tag, no_cache=no_cache)\n     logger.info(f\"Successfully built custom Docker image with tag {tag}\")\n", "issue": "Add docker build option to not use cache\nTo ensure fresh environment and while potentially developing a new model version users will not want to use cached layers in the docker build for their image.\r\n\r\nIn docker this is the --no-cache option, I would make it a boolean option within the cli and also add the --rm option (although default is true might be worth making sure) to remove any intermediate containers after success to again ensure a clean environment in CI/CD as well as locally. \n", "before_files": [{"content": "import subprocess\nimport os\n\nfrom tempfile import TemporaryDirectory\n\nfrom .. import __version__\nfrom ..logging import logger\n\nfrom .constants import (\n    DockerfileName,\n    DockerfileTemplate,\n    DockerignoreName,\n    Dockerignore,\n)\n\n\ndef generate_dockerfile() -> str:\n    return DockerfileTemplate.format(version=__version__)\n\n\ndef write_dockerfile(\n    folder: str, dockerfile: str, include_dockerignore: bool = True\n) -> str:\n    dockerfile_path = os.path.join(folder, DockerfileName)\n    with open(dockerfile_path, \"w\") as dockerfile_handler:\n        logger.info(f\"Writing Dockerfile in {dockerfile_path}\")\n        dockerfile_handler.write(dockerfile)\n\n    if include_dockerignore:\n        # Point to our own .dockerignore\n        # https://docs.docker.com/engine/reference/commandline/build/#use-a-dockerignore-file\n        dockerignore_path = dockerfile_path + DockerignoreName\n        with open(dockerignore_path, \"w\") as dockerignore_handler:\n            logger.info(f\"Writing .dockerignore in {dockerignore_path}\")\n            dockerignore_handler.write(Dockerignore)\n\n    return dockerfile_path\n\n\ndef build_image(folder: str, dockerfile: str, image_tag: str) -> str:\n    logger.info(f\"Building Docker image with tag {image_tag}\")\n    with TemporaryDirectory() as tmp_dir:\n        dockerfile_path = write_dockerfile(tmp_dir, dockerfile)\n\n        build_cmd = f\"docker build {folder} -f {dockerfile_path} -t {image_tag}\"\n        build_env = os.environ.copy()\n        build_env[\"DOCKER_BUILDKIT\"] = \"1\"\n        subprocess.run(build_cmd, check=True, shell=True, env=build_env)\n\n    return image_tag\n", "path": "mlserver/cli/build.py"}, {"content": "\"\"\"\nCommand-line interface to manage MLServer models.\n\"\"\"\nimport click\nimport asyncio\n\nfrom functools import wraps\n\nfrom ..server import MLServer\nfrom ..logging import logger, configure_logger\nfrom ..utils import install_uvloop_event_loop\n\nfrom .build import generate_dockerfile, build_image, write_dockerfile\nfrom .serve import load_settings\n\n\ndef click_async(f):\n    @wraps(f)\n    def wrapper(*args, **kwargs):\n        return asyncio.run(f(*args, **kwargs))\n\n    return wrapper\n\n\n@click.group()\n@click.version_option()\ndef root():\n    \"\"\"\n    Command-line interface to manage MLServer models.\n    \"\"\"\n    pass\n\n\n@root.command(\"start\")\n@click.argument(\"folder\", nargs=1)\n@click_async\nasync def start(folder: str):\n    \"\"\"\n    Start serving a machine learning model with MLServer.\n    \"\"\"\n    settings, models_settings = await load_settings(folder)\n\n    server = MLServer(settings)\n    await server.start(models_settings)\n\n\n@root.command(\"build\")\n@click.argument(\"folder\", nargs=1)\n@click.option(\"-t\", \"--tag\", type=str)\n@click_async\nasync def build(folder: str, tag: str):\n    \"\"\"\n    Build a Docker image for a custom MLServer runtime.\n    \"\"\"\n    dockerfile = generate_dockerfile()\n    build_image(folder, dockerfile, tag)\n    logger.info(f\"Successfully built custom Docker image with tag {tag}\")\n\n\n@root.command(\"dockerfile\")\n@click.argument(\"folder\", nargs=1)\n@click.option(\"-i\", \"--include-dockerignore\", is_flag=True)\n@click_async\nasync def dockerfile(folder: str, include_dockerignore: bool):\n    \"\"\"\n    Generate a Dockerfile\n    \"\"\"\n    dockerfile = generate_dockerfile()\n    dockerfile_path = write_dockerfile(\n        folder, dockerfile, include_dockerignore=include_dockerignore\n    )\n    logger.info(f\"Successfully written Dockerfile in {dockerfile_path}\")\n\n\ndef main():\n    configure_logger()\n    install_uvloop_event_loop()\n    root()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "mlserver/cli/main.py"}]}