code: def build(
      self,
      service_name,
      use_cache=True,
      use_leaf_cache=True,
      using_docker=False,
      using_buildx=False,
      pull_parents=True,
  ):
      def _build(service, use_cache):
          if "build" not in service:
              # nothing to do
              return
  
          args = []
          cache_from = list(
              service.get("build", {}).get("cache_from", [])
          )
          if pull_parents:
              for image in cache_from:
                  if image not in self.pull_memory:
                      try:
                          self._execute_docker("pull", image)
                      except Exception as e:
                          print(e)
                      finally:
                          self.pull_memory.add(image)
  
          if not use_cache:
              args.append("--no-cache")
  
          # turn on inline build cache, this is a docker buildx feature
          # used to bundle the image build cache to the pushed image manifest
          # so the build cache can be reused across hosts, documented at
          # https://github.com/docker/buildx#--cache-tonametypetypekeyvalue
          if self.config.env.get("BUILDKIT_INLINE_CACHE") == "1":
              args.extend(["--build-arg", "BUILDKIT_INLINE_CACHE=1"])
  
          if using_buildx:
              for k, v in service["build"].get("args", {}).items():
                  args.extend(["--build-arg", "{}={}".format(k, v)])
  
              if use_cache:
                  cache_ref = "{}-cache".format(service["image"])
                  cache_from = "type=registry,ref={}".format(cache_ref)
                  cache_to = "type=registry,ref={},mode=max".format(
                      cache_ref
                  )
                  args.extend(
                      [
                          "--cache-from",
                          cache_from,
                          "--cache-to",
                          cache_to,
                      ]
                  )
  
              args.extend(
                  [
                      "--output",
                      "type=docker",
                      "-f",
                      arrow_path(service["build"]["dockerfile"]),
                      "-t",
                      service["image"],
                      service["build"].get("context", "."),
                  ]
              )
              self._execute_docker("buildx", "build", *args)
          elif using_docker:
              # better for caching
              for k, v in service["build"].get("args", {}).items():
                  args.extend(["--build-arg", "{}={}".format(k, v)])
              for img in cache_from:
                  args.append('--cache-from="{}"'.format(img))
              args.extend(
                  [
                      "-f",
                      arrow_path(service["build"]["dockerfile"]),
                      "-t",
                      service["image"],
                      service["build"].get("context", "."),
                  ]
              )
              self._execute_docker("build", *args)
          else:
              self._execute_compose("build", *args, service["name"])
  
      service = self.config.get(service_name)
      # build ancestor services
      for ancestor in service["ancestors"]:
          _build(self.config.get(ancestor), use_cache=use_cache)
      # build the leaf/target service
      _build(service, use_cache=use_cache and use_leaf_cache)
  
imports: import os
  import shlex
  import subprocess
  from io import StringIO
  from dotenv import dotenv_values
  from ruamel.yaml import YAML
  from ..utils.command import Command, default_bin
  from ..utils.source import arrow_path
  from ..compat import _ensure_path
label_desc: Use image node_id 6 for calling the DockerCompose obj's underlying member method code with example usage: obj.build(service_name, use_cache, use_leaf_cache, using_docker, using_buildx, pull_parents) without return types