-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbase_docker_image_builder.py
40 lines (29 loc) · 1.13 KB
/
base_docker_image_builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Contains the base classes for Docker image builders."""
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict
from build_result import BuildResult
class BaseDockerImageBuilder(ABC):
"""Abstract base class for Docker image builders."""
@abstractmethod
async def build(self, code_id: str, file_path: Path) -> BuildResult:
"""Builds a Docker image.
If the image already exists, it will not be built again. So it is OK to call this method to
lookup the result.
Args:
file_path: The path to the tarball of the Docker context
Returns:
The tag to use for the docker image
"""
raise NotImplementedError
@abstractmethod
async def clean(self) -> None:
"""Removes all Docker images built by this builder."""
raise NotImplementedError
@abstractmethod
async def list(self) -> Dict[str, str]:
"""Lists all Docker images built by this builder.
Returns:
A dictionary mapping code IDs to the tags of their corresponding Docker images
"""
raise NotImplementedError