class_docstr: Container builder for building and pushing a Docker image.
class_docstr_tok: ["Container","builder","for","building","and","pushing","a","Docker","image","."]
docstr: Creates a Dockerfile.
docstr_tok: ["Creates","a","Dockerfile","."]
code: def _create_docker_file(self):
      """Creates a Dockerfile."""
      if self.docker_config:
          parent_image = self.docker_config.parent_image
      else:
          parent_image = None
      if parent_image is None:
          parent_image = self._get_docker_base_image()
  
      lines = [
          "FROM {}".format(parent_image),
          "WORKDIR {}".format(self.destination_dir),
      ]
  
      if self.requirements_txt is not None:
          _, requirements_txt_name = os.path.split(
              self.requirements_txt
          )
          dst_requirements_txt = os.path.join(requirements_txt_name)
          requirements_txt_path = os.path.join(
              self.destination_dir, requirements_txt_name
          )
          lines.append(
              "COPY {requirements_txt} {requirements_txt}".format(
                  requirements_txt=requirements_txt_path
              )
          )
          # install pip requirements from requirements_txt if it exists.
          lines.append(
              "RUN if [ -e {requirements_txt} ]; "
              "then pip install --no-cache -r {requirements_txt}; "
              "fi".format(requirements_txt=dst_requirements_txt)
          )
      if self.entry_point is None:
          lines.append("RUN pip install tensorflow-cloud")
  
      if (
          self.worker_config is not None
          and machine_config.is_tpu_config(self.worker_config)
      ):
          lines.append("RUN pip install cloud-tpu-client")
  
      # Copies the files from the `destination_dir` in Docker daemon location
      # to the `destination_dir` in Docker container filesystem.
      lines.append(
          "COPY {} {}".format(
              self.destination_dir, self.destination_dir
          )
      )
  
      docker_entry_point = (
          self.preprocessed_entry_point or self.entry_point
      )
      _, docker_entry_point_file_name = os.path.split(
          docker_entry_point
      )
  
      # Using `ENTRYPOINT` here instead of `CMD` specifically because
      # we want to support passing user code flags.
      lines.extend(
          [
              'ENTRYPOINT ["python", "{}"]'.format(
                  docker_entry_point_file_name
              )
          ]
      )
  
      content = "\n".join(lines)
      (
          self.docker_file_descriptor,
          self.docker_file_path,
      ) = tempfile.mkstemp()
      with open(self.docker_file_path, "w") as f:
          f.write(content)
  
imports: import logging
  import os
  import sys
  import tarfile
  import tempfile
  import time
  import uuid
  import warnings
  from .None import gcp
  from .None import machine_config
  import docker
  from google.cloud import storage
  from google.cloud.exceptions import NotFound
  from googleapiclient import discovery
  from googleapiclient import errors
  import requests
  from ..utils import google_api_client
  from ..utils import tf_utils
label_desc: Use image node_id 6 for calling the ContainerBuilder obj's underlying member method code with example usage: obj._create_docker_file() without return types