[Feature] Add render.com deployment template (#1033)
Co-authored-by: Deven Patel <iamdevenpatel@gmail.com>
This commit is contained in:
@@ -43,6 +43,7 @@ def setup_fly_io_app(extra_args):
|
||||
fly_launch_command = ["fly", "launch", "--region", "sjc", "--no-deploy"] + list(extra_args)
|
||||
try:
|
||||
console.print(f"🚀 [bold cyan]Running: {' '.join(fly_launch_command)}[/bold cyan]")
|
||||
shutil.move(".env.example", ".env")
|
||||
subprocess.run(fly_launch_command, check=True)
|
||||
console.print("✅ [bold green]'fly launch' executed successfully.[/bold green]")
|
||||
except subprocess.CalledProcessError as e:
|
||||
@@ -60,12 +61,41 @@ def setup_modal_com_app(extra_args):
|
||||
"""✅ [bold green]Modal setup already done. You can now install the dependencies by doing \n
|
||||
`pip install -r requirements.txt`[/bold green]"""
|
||||
)
|
||||
return
|
||||
modal_setup_cmd = ["modal", "setup"] + list(extra_args)
|
||||
console.print(f"🚀 [bold cyan]Running: {' '.join(modal_setup_cmd)}[/bold cyan]")
|
||||
subprocess.run(modal_setup_cmd, check=True)
|
||||
else:
|
||||
modal_setup_cmd = ["modal", "setup"] + list(extra_args)
|
||||
console.print(f"🚀 [bold cyan]Running: {' '.join(modal_setup_cmd)}[/bold cyan]")
|
||||
subprocess.run(modal_setup_cmd, check=True)
|
||||
shutil.move(".env.example", ".env")
|
||||
console.print("Great! Now you can install the dependencies by doing `pip install -r requirements.txt`")
|
||||
console.print(
|
||||
"""Great! Now you can install the dependencies by doing: \n
|
||||
`pip install -r requirements.txt`\n
|
||||
\n
|
||||
To run your app locally:\n
|
||||
`ec dev`
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def setup_render_com_app():
|
||||
render_setup_file = os.path.join(os.path.expanduser("~"), ".render/config.yaml")
|
||||
if os.path.exists(render_setup_file):
|
||||
console.print(
|
||||
"""✅ [bold green]Render setup already done. You can now install the dependencies by doing \n
|
||||
`pip install -r requirements.txt`[/bold green]"""
|
||||
)
|
||||
else:
|
||||
render_setup_cmd = ["render", "config", "init"]
|
||||
console.print(f"🚀 [bold cyan]Running: {' '.join(render_setup_cmd)}[/bold cyan]")
|
||||
subprocess.run(render_setup_cmd, check=True)
|
||||
shutil.move(".env.example", ".env")
|
||||
console.print(
|
||||
"""Great! Now you can install the dependencies by doing: \n
|
||||
`pip install -r requirements.txt`\n
|
||||
\n
|
||||
To run your app locally:\n
|
||||
`ec dev`
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@@ -75,15 +105,14 @@ def create(template, extra_args):
|
||||
anonymous_telemetry.capture(event_name="ec_create", properties={"template_used": template})
|
||||
src_path = get_pkg_path_from_name(template)
|
||||
shutil.copytree(src_path, os.getcwd(), dirs_exist_ok=True)
|
||||
env_sample_path = os.path.join(src_path, ".env.example")
|
||||
if os.path.exists(env_sample_path):
|
||||
shutil.copy(env_sample_path, os.path.join(os.getcwd(), ".env"))
|
||||
console.print(f"✅ [bold green]Successfully created app from template '{template}'.[/bold green]")
|
||||
|
||||
if template == "fly.io":
|
||||
setup_fly_io_app(extra_args)
|
||||
elif template == "modal.com":
|
||||
setup_modal_com_app(extra_args)
|
||||
elif template == "render.com":
|
||||
setup_render_com_app()
|
||||
else:
|
||||
raise ValueError(f"Unknown template '{template}'.")
|
||||
|
||||
@@ -123,6 +152,23 @@ def run_dev_modal_com():
|
||||
console.print("\n🛑 [bold yellow]FastAPI server stopped[/bold yellow]")
|
||||
|
||||
|
||||
def run_dev_render_com(debug, host, port):
|
||||
uvicorn_command = ["uvicorn", "app:app"]
|
||||
|
||||
if debug:
|
||||
uvicorn_command.append("--reload")
|
||||
|
||||
uvicorn_command.extend(["--host", host, "--port", str(port)])
|
||||
|
||||
try:
|
||||
console.print(f"🚀 [bold cyan]Running FastAPI app with command: {' '.join(uvicorn_command)}[/bold cyan]")
|
||||
subprocess.run(uvicorn_command, check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
console.print(f"❌ [bold red]An error occurred: {e}[/bold red]")
|
||||
except KeyboardInterrupt:
|
||||
console.print("\n🛑 [bold yellow]FastAPI server stopped[/bold yellow]")
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option("--debug", is_flag=True, help="Enable or disable debug mode.")
|
||||
@click.option("--host", default="127.0.0.1", help="The host address to run the FastAPI app on.")
|
||||
@@ -138,6 +184,8 @@ def dev(debug, host, port):
|
||||
run_dev_fly_io(debug, host, port)
|
||||
elif template == "modal.com":
|
||||
run_dev_modal_com()
|
||||
elif template == "render.com":
|
||||
run_dev_render_com(debug, host, port)
|
||||
else:
|
||||
raise ValueError(f"Unknown template '{template}'.")
|
||||
|
||||
@@ -212,6 +260,21 @@ def deploy_modal():
|
||||
)
|
||||
|
||||
|
||||
def deploy_render():
|
||||
render_deploy_cmd = ["render", "blueprint", "launch"]
|
||||
|
||||
try:
|
||||
console.print(f"🚀 [bold cyan]Running: {' '.join(render_deploy_cmd)}[/bold cyan]")
|
||||
subprocess.run(render_deploy_cmd, check=True)
|
||||
console.print("✅ [bold green]'render blueprint launch' executed successfully.[/bold green]")
|
||||
except subprocess.CalledProcessError as e:
|
||||
console.print(f"❌ [bold red]An error occurred: {e}[/bold red]")
|
||||
except FileNotFoundError:
|
||||
console.print(
|
||||
"❌ [bold red]'render' command not found. Please ensure Render CLI is installed and in your PATH.[/bold red]"
|
||||
)
|
||||
|
||||
|
||||
@cli.command()
|
||||
def deploy():
|
||||
# Check for platform-specific files
|
||||
@@ -225,5 +288,7 @@ def deploy():
|
||||
deploy_fly()
|
||||
elif template == "modal.com":
|
||||
deploy_modal()
|
||||
elif template == "render.com":
|
||||
deploy_render()
|
||||
else:
|
||||
console.print("❌ [bold red]No recognized deployment platform found.[/bold red]")
|
||||
|
||||
Reference in New Issue
Block a user