Merge pull request #978 from PlugNPush/main

Restore support for alt dockerfiles (removing hardcoded "Dockerfile")
This commit is contained in:
Povilas Kanapickas 2024-06-26 21:39:42 +03:00 committed by GitHub
commit d9a3572461
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 14 deletions

1
newsfragments/978.bugfix Normal file
View File

@ -0,0 +1 @@
Fixed support for de-facto alternative `Dockerfile` names (e.g. `Containerfile`)

View File

@ -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

View File

@ -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"}},