Skip to content

Commit

Permalink
Merge pull request #978 from PlugNPush/main
Browse files Browse the repository at this point in the history
Restore support for alt dockerfiles (removing hardcoded "Dockerfile")
  • Loading branch information
p12tic authored Jun 26, 2024
2 parents 0bcf079 + fa3e0a7 commit d9a3572
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions newsfragments/978.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed support for de-facto alternative `Dockerfile` names (e.g. `Containerfile`)
4 changes: 0 additions & 4 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 5 additions & 10 deletions tests/unit/test_normalize_final_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ class TestNormalizeFinalBuild(unittest.TestCase):
(
{"build": "."},
{
"build": {"context": cwd, "dockerfile": "Dockerfile"},
"build": {"context": cwd},
},
),
(
{"build": "../relative"},
{
"build": {
"context": os.path.normpath(os.path.join(cwd, "../relative")),
"dockerfile": "Dockerfile",
},
},
),
Expand All @@ -39,7 +38,6 @@ class TestNormalizeFinalBuild(unittest.TestCase):
{
"build": {
"context": os.path.normpath(os.path.join(cwd, "./relative")),
"dockerfile": "Dockerfile",
},
},
),
Expand All @@ -48,7 +46,6 @@ class TestNormalizeFinalBuild(unittest.TestCase):
{
"build": {
"context": "/workspace/absolute",
"dockerfile": "Dockerfile",
},
},
),
Expand All @@ -74,7 +71,6 @@ class TestNormalizeFinalBuild(unittest.TestCase):
{
"build": {
"context": cwd,
"dockerfile": "Dockerfile",
},
},
),
Expand Down Expand Up @@ -135,32 +131,31 @@ def test_parse_compose_file_when_single_compose(self, input, expected):
(
{},
{"build": "."},
{"build": {"context": cwd, "dockerfile": "Dockerfile"}},
{"build": {"context": cwd}},
),
(
{"build": "."},
{},
{"build": {"context": cwd, "dockerfile": "Dockerfile"}},
{"build": {"context": cwd}},
),
(
{"build": "/workspace/absolute"},
{"build": "./relative"},
{
"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"}},
Expand Down

0 comments on commit d9a3572

Please sign in to comment.