forked from thuasta/saiblo-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_docker_image_builder.py
38 lines (28 loc) · 1.07 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
"""Contains the base classes for Docker image builders."""
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict
class BaseDockerImageBuilder(ABC):
"""Abstract base class for Docker image builders."""
@abstractmethod
async def build(self, file_path: Path) -> str:
"""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[Path, str]:
"""Lists all Docker images built by this builder.
Returns:
A dictionary mapping paths to the tags of their corresponding Docker images
"""
raise NotImplementedError