You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Store these details securely in a `.env.production` file (you will need to set them later in application deployment as production secrets):
@@ -94,29 +89,6 @@ The disadvantages are:
94
89
- Install modal in the project directory with `uv add modal`
95
90
- Run `uv run modal setup` to authenticate with Modal
96
91
97
-
#### Setting Up Modal Secrets
98
-
99
-
The application relies on environment variables stored in `.env` (like `SECRET_KEY`, `DB_USER`, `DB_PASSWORD`, `DB_HOST`, `DB_PORT`, `DB_NAME`, `RESEND_API_KEY`, `BASE_URL`). These sensitive values should be stored securely using Modal Secrets.
100
-
101
-
Create a Modal Secret (e.g., named `fastapi-webapp-secrets`) either through the Modal UI or CLI:
You can probably guess what the `BASE_URL` will be from your user/organization name and the name of the Modal app, but you can also update it later after you get the official public base URL.
117
-
118
-
**Important:** Ensure `DB_HOST` points to your *cloud* database host address, not `localhost` or `host.docker.internal`.
119
-
120
92
#### Defining the Modal Image and App
121
93
122
94
Create a new Python file in the root of your project, for example, `deploy.py`. This file will define the Modal Image and the ASGI app deployment.
@@ -138,24 +110,20 @@ Create a new Python file in the root of your project, for example, `deploy.py`.
138
110
image = (
139
111
modal.Image.debian_slim(python_version="3.13")
140
112
.apt_install("libpq-dev", "libwebp-dev")
141
-
.pip_install("uv")
142
-
.run_commands(
143
-
# Install dependencies from pyproject.toml using uv
144
-
# Make sure uv sync handles psycopg2 correctly with libpq-dev present
@@ -188,16 +156,35 @@ For more information on Modal FastAPI images and applications, see [this guide](
188
156
189
157
#### Deploying the App
190
158
191
-
1. From your terminal, in the root directory of your project, run:
192
-
```bash
193
-
modal deploy deploy.py
194
-
```
195
-
Modal will build the image (if it hasn't been built before or if dependencies changed) and deploy the ASGI app. It will output a public URL (e.g., `https://your-username--your-app-name.modal.run`).
159
+
From your terminal, in the root directory of your project, run:
196
160
197
-
2. Once you have the public URLfrom Modal, make sure the `BASE_URL` variable in your Modal Secret matches this public URL. This is crucial for generating correct absolute URLs (e.g., in password reset emails). If you need to update the secret, run:
Redeploy if necessary (`modal deploy deploy.py`), although changes to secrets often take effect on subsequent container starts without a full redeploy.
161
+
```bash
162
+
modal deploy deploy.py
163
+
```
164
+
165
+
Modal will build the image (if it hasn't been built before or if dependencies changed) and deploy the ASGI app. It will output a public URL (e.g., `https://your-username--your-app-name.modal.run`).
166
+
167
+
#### Setting Up Modal Secrets
168
+
169
+
The application relies on environment variables stored in`.env` (like `SECRET_KEY`, `DB_USER`, `DB_PASSWORD`, `DB_HOST`, `DB_PORT`, `DB_NAME`, `RESEND_API_KEY`, `BASE_URL`). These sensitive values should be stored securely using Modal Secrets.
170
+
171
+
Create a Modal Secret either through the Modal UIorCLI. Note that the name of the secret has to match the secret name you used in the `deploy.py`file, above (e.g., `your-app-name-secret`).
**Important:** Ensure `DB_HOST` points to your *cloud* database host address, not`localhost`or`host.docker.internal`.
187
+
188
+
#### Testing the Deployment
202
189
203
-
3. Access the provided Modal URLin your browser. Browse the site and test the registration and password reset features to ensure database and Resend connections work correctly.
190
+
Access the provided Modal URLin your browser. Browse the site and test the registration and password reset features to ensure database and Resend connections work.
0 commit comments