Skip to content

Commit 4e45693

Browse files
Setup to deploy to modal
1 parent 29d47e5 commit 4e45693

File tree

3 files changed

+440
-0
lines changed

3 files changed

+440
-0
lines changed

deploy.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# deploy.py
2+
import modal
3+
4+
# Define the base image
5+
image = (
6+
modal.Image.debian_slim(python_version="3.13")
7+
.apt_install("libpq-dev", "libwebp-dev")
8+
.pip_install_from_pyproject("pyproject.toml")
9+
.add_local_python_source("main")
10+
.add_local_python_source("routers")
11+
.add_local_python_source("utils")
12+
.add_local_python_source("exceptions")
13+
.add_local_dir("static", remote_path="/root/static")
14+
.add_local_dir("templates", remote_path="/root/templates")
15+
)
16+
17+
# Define the Modal App
18+
app = modal.App(
19+
name="fastapi-jinja2-postgres-webapp",
20+
image=image,
21+
secrets=[modal.Secret.from_name("fastapi-jinja2-postgres-webapp")]
22+
)
23+
24+
25+
# Define the ASGI app function
26+
@app.function()
27+
@modal.asgi_app()
28+
def fastapi_app():
29+
from main import app as web_app
30+
31+
return web_app

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies = [
2121
"bcrypt<5.0.0,>=4.2.0",
2222
"fastapi<1.0.0,>=0.115.5",
2323
"pillow>=11.0.0",
24+
"modal>=0.73.162",
2425
]
2526

2627
[dependency-groups]

0 commit comments

Comments
 (0)