Skip to content

Commit 32c597f

Browse files
committed
fix(vercel): drop the legacy builds/routes config that conflicts with functions
1 parent 59773c7 commit 32c597f

5 files changed

Lines changed: 54 additions & 20 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ __pycache__/
77
*.egg-info/
88
.venv/
99
venv/
10-
.python-version
1110

1211
.pytest_cache/
1312
.ruff_cache/

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

.vercelignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Keep the serverless bundle under the 250 MB unzipped limit.
2+
#
3+
# Only api/ and app/ are needed at runtime. Everything below is development,
4+
# CI, or deployment tooling that would otherwise be uploaded and counted
5+
# against the limit.
6+
7+
tests/
8+
k8s/
9+
.github/
10+
scripts/
11+
12+
Dockerfile
13+
docker-compose.yml
14+
.dockerignore
15+
16+
# Migrations run from a developer machine or CI, never from the function —
17+
# two concurrent instances racing the same migration is worse than a manual
18+
# step. The golden set and corpus are eval fixtures, not runtime data.
19+
alembic.ini
20+
evals/
21+
22+
requirements-local.txt
23+
requirements-dev.txt
24+
25+
README.md
26+
.venv/
27+
.ruff_cache/
28+
.pytest_cache/

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,31 @@ cannot detect.
313313

314314
## Deploying to Vercel
315315

316-
```bash
317-
vercel --prod
316+
Import the repo at vercel.com/new. Project settings:
317+
318+
| Setting | Value |
319+
|---|---|
320+
| Application Preset | **FastAPI** |
321+
| Root Directory | `./` |
322+
| Install Command | `pip install -r requirements.txt` (the default) |
323+
| Build / Output | leave empty — [vercel.json](vercel.json) handles routing |
324+
325+
Environment variables:
326+
327+
```
328+
DATABASE_URL postgresql://…-pooler….neon.tech/db?sslmode=require # paste verbatim
329+
OPENAI_API_KEY sk-…
330+
ACTIVE_CONFIG serverless
331+
ENVIRONMENT vercel
332+
CORS_ORIGINS https://<your-frontend>.vercel.app
318333
```
319334

320-
Set `DATABASE_URL` (Neon, **pooled** connection string), `OPENAI_API_KEY`, `CORS_ORIGINS`, and
321-
`ACTIVE_CONFIG=serverless`. Run `alembic upgrade head` locally against the same database — the app
322-
does not migrate on boot, because two concurrent instances racing the same migration is worse than
323-
a manual step.
335+
`DATABASE_URL` is normalised on load, so the console's connection string works as-is — the driver
336+
is corrected and `sslmode`/`channel_binding` are translated into asyncpg connect arguments. Use the
337+
**pooled** host; the direct one exhausts connections under serverless.
338+
339+
Run `alembic upgrade head` **locally** against that database first. The app does not migrate on
340+
boot, because two concurrent instances racing the same migration is worse than a manual step.
324341

325342
### What is different on serverless, stated plainly
326343

vercel.json

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
{
22
"$schema": "https://openapi.vercel.sh/vercel.json",
3-
"version": 2,
4-
"builds": [
5-
{
6-
"src": "api/index.py",
7-
"use": "@vercel/python",
8-
"config": { "maxLambdaSize": "45mb", "runtime": "python3.12" }
9-
}
10-
],
11-
"routes": [{ "src": "/(.*)", "dest": "api/index.py" }],
123
"functions": {
134
"api/index.py": {
145
"maxDuration": 60,
15-
"memory": 1769
6+
"includeFiles": "app/**"
167
}
178
},
18-
"env": {
19-
"ENVIRONMENT": "vercel"
20-
}
9+
"rewrites": [{ "source": "/(.*)", "destination": "/api/index" }]
2110
}

0 commit comments

Comments
 (0)