def GenerateDockerfileData(self): """Generates dockerfiles. Returns: list(ext_runtime.GeneratedFile) the list of generated dockerfiles """ if self.runtime == 'python-compat': dockerfile_preamble = COMPAT_DOCKERFILE_PREAMBLE else: dockerfile_preamble = PYTHON27_DOCKERFILE_PREAMBLE all_config_files = [] dockerfile_name = config.DOCKERFILE dockerfile_components = [dockerfile_preamble, DOCKERFILE_INSTALL_APP] if self.runtime == 'python-compat': dockerfile_components.append(DOCKERFILE_INSTALL_REQUIREMENTS_TXT) dockerfile_contents = ''.join(c for c in dockerfile_components) dockerfile = ext_runtime.GeneratedFile(dockerfile_name, dockerfile_contents) all_config_files.append(dockerfile) dockerignore = ext_runtime.GeneratedFile('.dockerignore', DOCKERIGNORE) all_config_files.append(dockerignore) return all_config_files
def GetAllConfigFiles(self): all_config_files = [] # Generate app.yaml. if not self.params.appinfo: app_yaml_path = os.path.join(self.root, 'app.yaml') if not os.path.exists(app_yaml_path): runtime = 'custom' if self.params.custom else 'go' app_yaml_contents = GO_APP_YAML.format(runtime=runtime) app_yaml = ext_runtime.GeneratedFile('app.yaml', app_yaml_contents) all_config_files.append(app_yaml) if self.params.custom or self.params.deploy: dockerfile_path = os.path.join(self.root, images_config.DOCKERFILE) if not os.path.exists(dockerfile_path): dockerfile = ext_runtime.GeneratedFile( images_config.DOCKERFILE, DOCKERFILE) all_config_files.append(dockerfile) # Generate .dockerignore TODO(b/36051035): eventually this file will just # be copied verbatim. dockerignore_path = os.path.join(self.root, '.dockerignore') if not os.path.exists(dockerignore_path): dockerignore = ext_runtime.GeneratedFile( '.dockerignore', DOCKERIGNORE) all_config_files.append(dockerignore) return all_config_files
def _GenerateAppYaml(self): """Generates an app.yaml file appropriate to this application. Returns: (ext_runtime.GeneratedFile) A file wrapper for app.yaml """ app_yaml = os.path.join(self.root, 'app.yaml') runtime = 'custom' if self.params.custom else 'ruby' app_yaml_contents = APP_YAML_CONTENTS.format( runtime=runtime, entrypoint=self.entrypoint) app_yaml = ext_runtime.GeneratedFile('app.yaml', app_yaml_contents) return app_yaml
def _GenerateDockerfile(self): """Generates a Dockerfile appropriate to this application. Returns: (ext_runtime.GeneratedFile) A file wrapper for Dockerignore """ dockerfile_content = [DOCKERFILE_HEADER] if self.ruby_version: dockerfile_content.append( DOCKERFILE_CUSTOM_INTERPRETER.format(self.ruby_version)) else: dockerfile_content.append(DOCKERFILE_DEFAULT_INTERPRETER) if self.packages: dockerfile_content.append( DOCKERFILE_MORE_PACKAGES.format(' '.join(self.packages))) else: dockerfile_content.append(DOCKERFILE_NO_MORE_PACKAGES) dockerfile_content.append(DOCKERFILE_GEM_INSTALL) dockerfile_content.append(DOCKERFILE_ENTRYPOINT.format( self.entrypoint)) dockerfile = ext_runtime.GeneratedFile(config.DOCKERFILE, '\n'.join(dockerfile_content)) return dockerfile
def _GenerateDockerignore(self): """Generates a .dockerignore file appropriate to this application.""" dockerignore = os.path.join(self.root, '.dockerignore') dockerignore = ext_runtime.GeneratedFile('.dockerignore', DOCKERIGNORE_CONTENTS) return dockerignore