Skip to content

Commit 22e1584

Browse files
committed
Revert "fix compose not recognizing custom containerfile when in a git context"
This reverts commit df7aa40. Signed-off-by: Metroite <[email protected]>
1 parent 1d4e92f commit 22e1584

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

podman_compose.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,34 +2883,35 @@ def cleanup_temp_dockfile() -> None:
28832883
cleanup_callbacks.append(cleanup_temp_dockfile)
28842884

28852885
build_args = []
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:
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:
29012890
dockerfile = os.path.join(ctx, dockerfile)
2902-
if path_exists(dockerfile):
2903-
break
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
29042905

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}")
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}")
29142915

29152916
build_args.extend(["-t", cnt["image"]])
29162917

0 commit comments

Comments
 (0)