blob: 71eb6e95cac75abed21e44662048c0a0b7d62678 [file]
"""Recipe for building and depoying the docker image used by the testing team.
"""
import os
from slave import base_recipe
from slave.step import docker_testing_image_step
from slave.step import docker_push_testing_step
DOCKER_INFORMATION = {
'docker_testing_image': {
'bucket': 'gcr.io/google.com/home-ci-controller-staging/home-testing',
'path_info': {
'project': 'test',
'dockerfile': 'docker_images'} # Path in project to Dockerfile
}
}
def GetValidBuildNames():
return ['docker_testing_image',]
def CreateRecipe(build_name: str, **kwargs):
bucket = DOCKER_INFORMATION[build_name]['bucket']
path_info = DOCKER_INFORMATION[build_name]['path_info']
return DockerTestingImageRecipe(
bucket=bucket,
path_info=path_info,
**kwargs)
class DockerTestingImageRecipe(base_recipe.BaseRecipe):
"""Recipe to build and push the Docker image that will be used by the home
testing team.
Args:
bucket: The URL of the docker bucket where the image will be pushed and
stored
path_info: Dictionary to have the project and internal path to the
Dockerfile. For example:
'path_info': {
'project': 'project_repo',
'dockerfile': 'path/to/dockerfile/folder'
}
Returns:
Steps for build and push docker images.
"""
def __init__(self, bucket, path_info, **kwargs):
base_recipe.BaseRecipe.__init__(self, **kwargs)
self._path_info = path_info
self._docker_bucket = bucket
def get_steps(self):
steps = [
docker_testing_image_step.DockerImageBuildStep(
self._docker_bucket,
self._path_info,
**self._step_kwargs),
docker_push_testing_step.DockerPushTestingStep(
self._docker_bucket,
self._path_info,
**self._step_kwargs)
]
return steps