@@ -24,7 +24,9 @@ class DockerImage:
2424            ...    logs = image.get_logs() 
2525
2626    :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 
2830    """ 
2931
3032    def  __init__ (
@@ -33,6 +35,8 @@ def __init__(
3335        docker_client_kw : Optional [dict ] =  None ,
3436        tag : Optional [str ] =  None ,
3537        clean_up : bool  =  True ,
38+         dockerfile_path : Union [str , PathLike ] =  "Dockerfile" ,
39+         no_cache : bool  =  False ,
3640        ** kwargs ,
3741    ) ->  None :
3842        self .tag  =  tag 
@@ -42,11 +46,15 @@ def __init__(
4246        self ._kwargs  =  kwargs 
4347        self ._image  =  None 
4448        self ._logs  =  None 
49+         self ._dockerfile_path  =  dockerfile_path 
50+         self ._no_cache  =  no_cache 
4551
4652    def  build (self , ** kwargs ) ->  Self :
4753        logger .info (f"Building image from { self .path }  )
4854        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+         )
5058        logger .info (f"Built image { self .short_id } { self .tag }  )
5159        return  self 
5260
0 commit comments