@@ -24,7 +24,9 @@ class DockerImage:
24
24
... logs = image.get_logs()
25
25
26
26
:param tag: Tag for the image to be built (default: None)
27
- :param path: Path to the Dockerfile to build the image
27
+ :param path: Path to the build context
28
+ :param dockerfile_path: Path to the Dockerfile within the build context path (default: Dockerfile)
29
+ :param no_cache: Bypass build cache; CLI's --no-cache
28
30
"""
29
31
30
32
def __init__ (
@@ -33,6 +35,8 @@ def __init__(
33
35
docker_client_kw : Optional [dict ] = None ,
34
36
tag : Optional [str ] = None ,
35
37
clean_up : bool = True ,
38
+ dockerfile_path : Union [str , PathLike ] = "Dockerfile" ,
39
+ no_cache : bool = False ,
36
40
** kwargs ,
37
41
) -> None :
38
42
self .tag = tag
@@ -42,11 +46,15 @@ def __init__(
42
46
self ._kwargs = kwargs
43
47
self ._image = None
44
48
self ._logs = None
49
+ self ._dockerfile_path = dockerfile_path
50
+ self ._no_cache = no_cache
45
51
46
52
def build (self , ** kwargs ) -> Self :
47
53
logger .info (f"Building image from { self .path } " )
48
54
docker_client = self .get_docker_client ()
49
- self ._image , self ._logs = docker_client .build (path = str (self .path ), tag = self .tag , ** kwargs )
55
+ self ._image , self ._logs = docker_client .build (
56
+ path = str (self .path ), tag = self .tag , dockerfile = self ._dockerfile_path , nocache = self ._no_cache , ** kwargs
57
+ )
50
58
logger .info (f"Built image { self .short_id } with tag { self .tag } " )
51
59
return self
52
60
0 commit comments