@@ -2883,35 +2883,34 @@ def cleanup_temp_dockfile() -> None:
28832883 cleanup_callbacks .append (cleanup_temp_dockfile )
28842884
28852885 build_args = []
2886- # if givent context was not recognized as git url, try joining paths to get a file locally
2887- if not is_context_git_url (ctx ):
2888- custom_dockerfile_given = False
2889- if dockerfile :
2886+
2887+ custom_dockerfile_given = False
2888+ if dockerfile :
2889+ dockerfile = os .path .join (ctx , dockerfile )
2890+ custom_dockerfile_given = True
2891+ else :
2892+ dockerfile_alts = [
2893+ "Containerfile" ,
2894+ "ContainerFile" ,
2895+ "containerfile" ,
2896+ "Dockerfile" ,
2897+ "DockerFile" ,
2898+ "dockerfile" ,
2899+ ]
2900+ for dockerfile in dockerfile_alts :
28902901 dockerfile = os .path .join (ctx , dockerfile )
2891- custom_dockerfile_given = True
2892- else :
2893- dockerfile_alts = [
2894- "Containerfile" ,
2895- "ContainerFile" ,
2896- "containerfile" ,
2897- "Dockerfile" ,
2898- "DockerFile" ,
2899- "dockerfile" ,
2900- ]
2901- for dockerfile in dockerfile_alts :
2902- dockerfile = os .path .join (ctx , dockerfile )
2903- if path_exists (dockerfile ):
2904- break
2902+ if path_exists (dockerfile ):
2903+ break
29052904
2906- if path_exists (dockerfile ):
2907- # normalize dockerfile path, as the user could have provided unpredictable file formats
2908- dockerfile = os .path .normpath (os .path .join (ctx , dockerfile ))
2909- build_args .extend (["-f" , dockerfile ])
2910- else :
2911- if custom_dockerfile_given :
2912- # custom dockerfile name was also not found in the file system
2913- raise OSError (f"Dockerfile not found in { dockerfile } " )
2914- raise OSError (f"Dockerfile not found in { ctx } " )
2905+ if path_exists (dockerfile ):
2906+ # normalize dockerfile path, as the user could have provided unpredictable file formats
2907+ dockerfile = os .path .normpath (os .path .join (ctx , dockerfile ))
2908+ build_args .extend (["-f" , dockerfile ])
2909+ else :
2910+ if custom_dockerfile_given :
2911+ # custom dockerfile name was also not found in the file system
2912+ raise OSError (f"Dockerfile not found in { dockerfile } " )
2913+ raise OSError (f"Dockerfile not found in { ctx } " )
29152914
29162915 build_args .extend (["-t" , cnt ["image" ]])
29172916
0 commit comments