Skip to content

Commit d0626bd

Browse files
authored
Merge pull request #177 from morph-data/fix/change-use-custom-dockerfile
change logic for checking use_custom_dockerfile
2 parents 79746ed + 0552e28 commit d0626bd

2 files changed

Lines changed: 12 additions & 20 deletions

File tree

core/morph/config/project.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
class BuildConfig(BaseModel):
17-
use_custom_dockerfile: bool = False
1817
runtime: Optional[str] = None
1918
framework: Optional[str] = "morph"
2019
package_manager: Optional[str] = None
@@ -101,7 +100,6 @@ def dump_project_yaml(project: MorphProject) -> str:
101100
source_paths = "\n- ".join([""] + project.source_paths)
102101

103102
# Default values
104-
build_use_custom_dockerfile = "false"
105103
build_runtime = ""
106104
build_framework = ""
107105
build_package_manager = ""
@@ -120,10 +118,6 @@ def dump_project_yaml(project: MorphProject) -> str:
120118

121119
# Set values if build exists
122120
if project.build:
123-
if project.build.use_custom_dockerfile is not None:
124-
build_use_custom_dockerfile = str(
125-
project.build.use_custom_dockerfile
126-
).lower()
127121
if project.build.runtime:
128122
build_runtime = project.build.runtime or ""
129123
if project.build.framework:
@@ -168,23 +162,24 @@ def dump_project_yaml(project: MorphProject) -> str:
168162
deployment_provider = "aws"
169163

170164
return f"""
171-
# Cloud Settings
172-
profile: {project.profile} # Defined in the Profile Section in `~/.morph/credentials`
173-
project_id: {project.project_id or "null"}
165+
version: '1'
174166
175167
# Framework Settings
176168
default_connection: {project.default_connection}
177169
source_paths:{source_paths}
178170
171+
# Cloud Settings
172+
# profile: {project.profile} # Defined in the Profile Section in `~/.morph/credentials`
173+
# project_id: {project.project_id or "null"}
174+
179175
# Build Settings
180176
build:
181-
use_custom_dockerfile: {build_use_custom_dockerfile}
182-
# These settings are required when use_custom_dockerfile is false
177+
# These settings are required when there is no Dockerfile in the project root.
183178
# They define the environment in which the project will be built
184179
runtime: {build_runtime} # python3.9, python3.10, python3.11, python3.12
185180
framework: {build_framework}
186181
package_manager: {build_package_manager} # pip, poetry, uv
187-
# These settings are required when use_custom_dockerfile is true
182+
# These settings are required when there is a Dockerfile in the project root.
188183
# They define how the Docker image will be built
189184
# context: {build_context}
190185
# build_args:{build_args_str}

core/morph/task/deploy.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ def __init__(self, args: Flags):
5050
self.package_manager = self.project.package_manager
5151

5252
# Check Dockerfile existence
53-
self.dockerfile = os.path.join(self.project_root, "Dockerfile")
54-
if self.project.build is not None and self.project.build.use_custom_dockerfile:
55-
if not os.path.exists(self.dockerfile):
56-
click.echo(click.style(f"Error: {self.dockerfile} not found", fg="red"))
57-
sys.exit(1)
58-
else:
53+
self.dockerfile_path = os.path.join(self.project_root, "Dockerfile")
54+
self.use_custom_dockerfile = os.path.exists(self.dockerfile_path)
55+
if self.use_custom_dockerfile:
5956
provider = "aws"
6057
if (
6158
self.project.deployment is not None
@@ -73,7 +70,7 @@ def __init__(self, args: Flags):
7370
self.project.build.package_manager,
7471
self.project.build.runtime,
7572
)
76-
with open(self.dockerfile, "w") as f:
73+
with open(self.dockerfile_path, "w") as f:
7774
f.write(dockerfile)
7875
dockerignore_path = os.path.join(self.project_root, ".dockerignore")
7976
with open(dockerignore_path, "w") as f:
@@ -440,7 +437,7 @@ def _build_docker_image(self) -> str:
440437
"-t",
441438
self.image_name,
442439
"-f",
443-
self.dockerfile,
440+
self.dockerfile_path,
444441
self.project_root,
445442
]
446443
if self.no_cache:

0 commit comments

Comments
 (0)