Skip to content

Commit 690a171

Browse files
rlafurudclaude
andcommitted
chore(deploy): free Vercel + Render config
- api.js: use VITE_API_BASE in production, fall back to the Vite /api proxy in dev so nothing changes locally. - render.yaml: free FastAPI web service (not serverless — the LLM pipeline needs long request timeouts); OPENAI_API_KEY set as a dashboard secret. - frontend/vercel.json + .env.example: Vite build + SPA routing + API base. - DEPLOY.md: step-by-step, notes that /launch is local-only and that LLM calls are billed to the OpenAI key even though hosting is free. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2b4df32 commit 690a171

5 files changed

Lines changed: 70 additions & 2 deletions

File tree

DEPLOY.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 배포 가이드 (무료: Vercel + Render)
2+
3+
프론트엔드(정적 SPA)는 Vercel에, 백엔드(FastAPI)는 Render에 올리는 무료 구성입니다.
4+
5+
> ⚠️ **"BAR에서 실행"(`/launch`)은 배포본에서 동작하지 않습니다.** 그 기능은 백엔드가 도는
6+
> 머신의 데스크톱에서 `spring.exe`를 띄우는 것이라, 화면도 BAR도 없는 클라우드 서버에선
7+
> 불가능합니다. 배포본에서는 자동으로 "launcher not found"로 안전하게 실패하고, 브라우저
8+
> 근사 플레이백(SimPlayback)은 정상 동작합니다.
9+
>
10+
> ⚠️ **호스팅은 무료지만 LLM 호출은 본인 OpenAI 키로 과금됩니다.** (토큰만큼)
11+
12+
## 1. 백엔드 — Render (무료 Web Service)
13+
14+
1. Render Dashboard → **New → Blueprint** → 이 저장소 선택 → 루트의 [`render.yaml`](render.yaml) 감지.
15+
2. 환경변수 `OPENAI_API_KEY` 를 Render 대시보드에서 입력 (절대 커밋 금지).
16+
3. 배포 후 URL 확인 (예: `https://rtsgame-backend.onrender.com`).
17+
18+
- 무료 티어는 15분 무활동 시 **슬립** → 첫 요청에 1분+ 콜드스타트. 발표 직전 `/health` 한 번
19+
호출해 깨워두거나 외부 cron으로 5~10분마다 ping.
20+
- LLM 응답이 수십 초~2분 걸리므로 **서버리스(Vercel/Netlify Functions)에는 백엔드를 두면 안 됩니다**
21+
(짧은 타임아웃에 끊김). Render 같은 상시 컨테이너여야 합니다.
22+
23+
## 2. 프론트엔드 — Vercel (무료)
24+
25+
1. Vercel → **New Project** → 이 저장소 선택.
26+
2. **Root Directory = `frontend`** 로 지정 ([`frontend/vercel.json`](frontend/vercel.json)이 빌드/SPA 라우팅 처리).
27+
3. 환경변수 **`VITE_API_BASE`** = 위 Render 백엔드 URL (예: `https://rtsgame-backend.onrender.com`).
28+
4. 배포.
29+
30+
`VITE_API_BASE`가 없으면(로컬 dev) 자동으로 Vite 프록시(`/api``localhost:8000`)를 씁니다.
31+
프로덕션에서만 이 변수로 실제 백엔드를 가리킵니다. — [frontend/src/api.js](frontend/src/api.js)
32+
33+
## 3. 확인
34+
35+
- 백엔드: `https://<render-url>/health``{"status":"ok"}`
36+
- 프론트: Vercel URL 접속 → 프롬프트 생성 → 결과/플레이백 표시.
37+
(첫 생성은 Render 콜드스타트로 느릴 수 있음.)

frontend/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copy to .env.local for local overrides, or set in the Vercel project settings.
2+
# Leave UNSET in local dev so calls go through the Vite proxy (/api).
3+
# In production, point this at the deployed backend origin:
4+
VITE_API_BASE=https://rtsgame-backend.onrender.com

frontend/src/api.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// All calls go through the Vite proxy (/api -> http://localhost:8000).
2-
const BASE = '/api'
1+
// In dev, calls go through the Vite proxy (/api -> http://localhost:8000).
2+
// In production set VITE_API_BASE to the deployed backend origin
3+
// (e.g. https://rtsgame-backend.onrender.com) at build time.
4+
const BASE = import.meta.env.VITE_API_BASE ?? '/api'
35

46
export async function getCatalog() {
57
const res = await fetch(`${BASE}/catalog`)

frontend/vercel.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"buildCommand": "npm run build",
4+
"outputDirectory": "dist",
5+
"framework": "vite",
6+
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
7+
}

render.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Render Blueprint — free backend hosting for the FastAPI generator.
2+
# Deploy: Render Dashboard -> New -> Blueprint -> pick this repo.
3+
# A web service (not serverless) so the slow multi-call LLM pipeline isn't
4+
# cut off by a short function timeout.
5+
services:
6+
- type: web
7+
name: rtsgame-backend
8+
runtime: python
9+
plan: free # free tier: sleeps after 15 min idle (cold start ~1 min)
10+
rootDir: backend
11+
buildCommand: pip install -r requirements.txt
12+
startCommand: uvicorn app:app --host 0.0.0.0 --port $PORT
13+
healthCheckPath: /health
14+
envVars:
15+
- key: OPENAI_API_KEY
16+
sync: false # set this secret in the Render dashboard, never commit it
17+
- key: PYTHON_VERSION
18+
value: "3.11"

0 commit comments

Comments
 (0)