From fa3e0a7772fbce87449f7cb549bb28a354fbf87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Nass=20-=20PlugN?= Date: Wed, 26 Jun 2024 15:24:58 +0200 Subject: [PATCH] Alt Dockerfile names fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michaƫl Nass - PlugN --- newsfragments/978.bugfix | 1 + podman_compose.py | 4 ---- tests/unit/test_normalize_final_build.py | 15 +++++---------- 3 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 newsfragments/978.bugfix diff --git a/newsfragments/978.bugfix b/newsfragments/978.bugfix new file mode 100644 index 0000000..6b155a3 --- /dev/null +++ b/newsfragments/978.bugfix @@ -0,0 +1 @@ +Fixed support for de-facto alternative `Dockerfile` names (e.g. `Containerfile`) diff --git a/podman_compose.py b/podman_compose.py index f424169..200ce78 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -1527,12 +1527,8 @@ def normalize_service_final(service: dict, project_dir: str) -> dict: build = service["build"] context = build if is_str(build) else build.get("context", ".") context = os.path.normpath(os.path.join(project_dir, context)) - dockerfile = ( - "Dockerfile" if is_str(build) else service["build"].get("dockerfile", "Dockerfile") - ) if not is_dict(service["build"]): service["build"] = {} - service["build"]["dockerfile"] = dockerfile service["build"]["context"] = context return service diff --git a/tests/unit/test_normalize_final_build.py b/tests/unit/test_normalize_final_build.py index 6356d3e..34ba0ea 100644 --- a/tests/unit/test_normalize_final_build.py +++ b/tests/unit/test_normalize_final_build.py @@ -22,7 +22,7 @@ class TestNormalizeFinalBuild(unittest.TestCase): ( {"build": "."}, { - "build": {"context": cwd, "dockerfile": "Dockerfile"}, + "build": {"context": cwd}, }, ), ( @@ -30,7 +30,6 @@ class TestNormalizeFinalBuild(unittest.TestCase): { "build": { "context": os.path.normpath(os.path.join(cwd, "../relative")), - "dockerfile": "Dockerfile", }, }, ), @@ -39,7 +38,6 @@ class TestNormalizeFinalBuild(unittest.TestCase): { "build": { "context": os.path.normpath(os.path.join(cwd, "./relative")), - "dockerfile": "Dockerfile", }, }, ), @@ -48,7 +46,6 @@ class TestNormalizeFinalBuild(unittest.TestCase): { "build": { "context": "/workspace/absolute", - "dockerfile": "Dockerfile", }, }, ), @@ -74,7 +71,6 @@ class TestNormalizeFinalBuild(unittest.TestCase): { "build": { "context": cwd, - "dockerfile": "Dockerfile", }, }, ), @@ -135,12 +131,12 @@ class TestNormalizeFinalBuild(unittest.TestCase): ( {}, {"build": "."}, - {"build": {"context": cwd, "dockerfile": "Dockerfile"}}, + {"build": {"context": cwd}}, ), ( {"build": "."}, {}, - {"build": {"context": cwd, "dockerfile": "Dockerfile"}}, + {"build": {"context": cwd}}, ), ( {"build": "/workspace/absolute"}, @@ -148,19 +144,18 @@ class TestNormalizeFinalBuild(unittest.TestCase): { "build": { "context": os.path.normpath(os.path.join(cwd, "./relative")), - "dockerfile": "Dockerfile", } }, ), ( {"build": "./relative"}, {"build": "/workspace/absolute"}, - {"build": {"context": "/workspace/absolute", "dockerfile": "Dockerfile"}}, + {"build": {"context": "/workspace/absolute"}}, ), ( {"build": "./relative"}, {"build": "/workspace/absolute"}, - {"build": {"context": "/workspace/absolute", "dockerfile": "Dockerfile"}}, + {"build": {"context": "/workspace/absolute"}}, ), ( {"build": {"dockerfile": "test-dockerfile"}},