diff --git a/tools/deployment-cli-tools/ch_cli_tools/skaffold.py b/tools/deployment-cli-tools/ch_cli_tools/skaffold.py index 774234b9..c0de5764 100644 --- a/tools/deployment-cli-tools/ch_cli_tools/skaffold.py +++ b/tools/deployment-cli-tools/ch_cli_tools/skaffold.py @@ -143,7 +143,8 @@ def process_build_dockerfile(dockerfile_path, root_path, global_context=False, r def identify_unicorn_based_main(candidates): import re gunicorn_pattern = re.compile(r"gunicorn") - for candidate in candidates: + # sort candidates, shortest path first + for candidate in sorted(candidates,key=lambda x: len(x.split("/"))): dockerfile_path = f"{candidate}/.." while not exists(f"{dockerfile_path}/Dockerfile") and abspath(dockerfile_path) != abspath(root_path): dockerfile_path += "/.."