def docker_build_sub(ref, context, extra_cmds, child_context=None, base_suffix='-tilt_docker_build_sub_base', live_update=[], **kwargs):
  """
  Substitutes in a docker image with extra Dockerfile commands.

  This allows you to easily customize your docker build for your dev environment without changing your prod Dockerfile.

  This works by:
  1. Renaming the original image to, e.g. "myimage-base"
  2. Creating a new image named, e.g. "myimage" that starts with "FROM myimage-base"
  3. Adding whatever extra stuff you want

  Examples:
  ```
  # load the extension
  load("ext://docker_build_sub", "docker_build_sub")

  # ensure you have vim installed when running in dev, so you can
  # shell into the box and look at files
  docker_build_sub('myimage', '.', extra_cmds=["apt-get install vim"])

  # use live_update to sync files from outside your docker context
  docker_build_sub('foo', 'foo', child_context='bar',
    extra_cmds=['ADD . /bar'],
    live_update=[
      sync('foo', '/foo'),
      sync('bar', '/bar'),
    ]
  )
  ```

  This function supports all the normal `docker_build` arguments. See [docker_build API docs](https://docs.tilt.dev/api.html#api.docker_build) for arguments not mentioned here..

  Args:
    context (str): The directory in which to build the parent (original) image. If child_context is not set, also the directory in which to build the new child image.
    extra_cmds (List[str]): Any extra Dockerfile commands you want to run when building the image.
    child_context (str): The directory in which to build the new child image. If unset (None), defaults to the parent image's context.
    base_suffix (str): The suffix to append to the parent (original) image's name so that the new child image can take the original name. This is mostly ignorable, and just here in case the default generates a conflict for you.
  """
  if not child_context:
    child_context = context
  base_ref = '%s-base' % ref
  docker_build(base_ref, context, **kwargs)
  df = '\n'.join(['FROM %s' % base_ref] + extra_cmds)
  docker_build(ref, child_context, dockerfile_contents=df, live_update=live_update, **kwargs)
