def _image_tag_for_project(project_id: str,
                           image_id: str,
                           include_tag: bool = True) -> str:
  """Generate the GCR Docker image tag for the supplied pair of project_id and
  image_id.

  This function properly handles "domain scoped projects", where the project ID
  contains a domain name and project ID separated by :
  https://cloud.google.com/container-registry/docs/overview#domain-scoped_projects.

  """
  project_s = project_id.replace(":", "/")
  base = f"gcr.io/{project_s}/{image_id}"
  return f"{base}:latest" if include_tag else base