Skip to content

Commit 8c3562f

Browse files
feat(deploy): add free cloud deployment via Render API and Vercel web
1 parent aab6663 commit 8c3562f

File tree

7 files changed

+81
-14
lines changed

7 files changed

+81
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ venv/
1111
*.egg-info/
1212
node_modules/
1313
.next/
14+
.vercel/
1415
.expo/
1516
.expo-shared/
1617
dist/

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VENV ?= .venv
22
PYTHON ?= $(VENV)/bin/python
33
PIP ?= $(VENV)/bin/pip
44

5-
.PHONY: setup test lint demo paper deploy stop deploy-public stop-public
5+
.PHONY: setup test lint demo paper deploy stop deploy-public stop-public deploy-vercel
66

77
setup:
88
python3 -m venv $(VENV)
@@ -49,3 +49,6 @@ deploy-public:
4949

5050
stop-public:
5151
./scripts/stop_public.sh
52+
53+
deploy-vercel:
54+
./scripts/deploy_vercel.sh

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,11 @@ make deploy
5656
make stop
5757
make deploy-public
5858
make stop-public
59+
make deploy-vercel
5960
```
61+
62+
## Free Cloud Deploy
63+
64+
- API: deploy `render.yaml` on Render Blueprint (free web service).
65+
- Web: deploy `web/` on Vercel Hobby with `NEXT_PUBLIC_API_BASE` set to the Render API URL.
66+
- Full steps: `docs/DEPLOYMENT.md`.

docker/server.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ RUN pip install --no-cache-dir --upgrade pip \
1414
&& pip install --no-cache-dir -e core -e planners -e worldmodels -e agents -e server
1515

1616
EXPOSE 8000
17-
CMD ["uvicorn", "worldmodel_server.main:app", "--host", "0.0.0.0", "--port", "8000"]
17+
CMD ["sh", "-c", "uvicorn worldmodel_server.main:app --host 0.0.0.0 --port ${PORT:-8000}"]

docs/DEPLOYMENT.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Deployment
22

3+
## Recommended Free Cloud Combo: Render (API) + Vercel (Web)
4+
5+
This project supports a fully free setup for hobby usage:
6+
- API on Render free web service
7+
- Next.js web app on Vercel Hobby
8+
9+
### 1) Deploy API on Render
10+
11+
1. Open [Render Dashboard](https://dashboard.render.com/).
12+
2. Click **New +** -> **Blueprint**.
13+
3. Connect this repo and deploy using `/render.yaml`.
14+
4. After deploy, copy your API URL (for example `https://worldmodel-gym-api.onrender.com`).
15+
16+
Notes:
17+
- Render free web services can spin down when idle.
18+
- This repo uses sqlite in `/tmp` on Render free tier (ephemeral storage).
19+
20+
### 2) Deploy Web on Vercel
21+
22+
1. Open [Vercel Dashboard](https://vercel.com/new) and import this GitHub repo.
23+
2. Set **Root Directory** to `web`.
24+
3. Add environment variable:
25+
- `NEXT_PUBLIC_API_BASE=https://<your-render-api-url>`
26+
4. Deploy.
27+
28+
Optional CLI deploy:
29+
30+
```bash
31+
make deploy-vercel
32+
```
33+
334
## Local Production Mode
435

536
Run API + web on your machine:
@@ -14,28 +45,27 @@ Stop local services:
1445
make stop
1546
```
1647

17-
## Public No-Card Deployment (Quick Tunnel)
48+
## Public No-Card Tunnel Mode
1849

19-
This mode does not require Fly.io, cloud billing, or credit card setup.
50+
This mode does not require cloud accounts or credit card setup.
2051
It runs services locally and exposes temporary public URLs through `localtunnel`.
2152

2253
```bash
2354
make deploy-public
2455
```
2556

26-
The command will:
27-
- start API (`uvicorn`) on `127.0.0.1:8000`
28-
- create a public API tunnel URL
29-
- build web with `NEXT_PUBLIC_API_BASE=<public-api-url>`
30-
- start web on `127.0.0.1:3000`
31-
- create a public web tunnel URL
32-
33-
Stop public deployment:
57+
Stop:
3458

3559
```bash
3660
make stop-public
3761
```
3862

3963
Notes:
40-
- Public tunnel URLs are ephemeral and change when restarted.
41-
- Keep your machine running while the public URLs are in use.
64+
- URLs are ephemeral and change when restarted.
65+
- Keep your machine running while URLs are in use.
66+
67+
## References
68+
69+
- Render Free tier and pricing: https://render.com/pricing
70+
- Render blueprint spec (`render.yaml`): https://render.com/docs/blueprint-spec
71+
- Vercel plans and Hobby usage: https://vercel.com/pricing

render.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
- type: web
3+
name: worldmodel-gym-api
4+
env: docker
5+
dockerfilePath: ./docker/server.Dockerfile
6+
dockerContext: .
7+
plan: free
8+
healthCheckPath: /healthz
9+
autoDeploy: true
10+
envVars:
11+
- key: WMG_DB_URL
12+
value: sqlite:////tmp/worldmodel_gym.db
13+
- key: WMG_STORAGE_DIR
14+
value: /tmp/storage
15+
- key: WMG_UPLOAD_TOKEN
16+
generateValue: true

scripts/deploy_vercel.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$ROOT_DIR/web"
6+
7+
echo "Deploying web to Vercel (Hobby)."
8+
echo "If not logged in, this command will open interactive login."
9+
10+
npx vercel --prod

0 commit comments

Comments
 (0)