Spaces:
Sleeping
Sleeping
|
Download DEPLOY.md from Sebacu/saniplus-chatbot: direct link, hf CLI and curl.
- Browser
- Download file 3.38 kB
-
https://huggingface.co/spaces/Sebacu/saniplus-chatbot/resolve/main/DEPLOY.md
- Command line
-
hf download hf://spaces/Sebacu/saniplus-chatbot/DEPLOY.md
-
curl -L -o DEPLOY.md https://huggingface.co/spaces/Sebacu/saniplus-chatbot/resolve/main/DEPLOY.md
3.38 kB
| # Deploying the SaniPlus chatbot to Render | |
| A public, shareable showcase URL in ~10 minutes. The app is protected by a | |
| shared access code, and your Anthropic API key stays server-side. | |
| ## What you need | |
| - A GitHub account | |
| - A Render account (https://render.com β free tier is fine) | |
| - Your Anthropic API key (`sk-ant-...`) | |
| - An access code you invent (e.g. `saniplus2026`) | |
| --- | |
| ## Step 1 β Put this folder in a GitHub repo | |
| From inside `saniplus-chatbot-llm/`: | |
| ```powershell | |
| git init | |
| git add . | |
| git commit -m "SaniPlus chatbot (LLM-backed) showcase" | |
| # create an empty repo on github.com first, then: | |
| git remote add origin https://github.com/<you>/saniplus-chatbot.git | |
| git branch -M main | |
| git push -u origin main | |
| ``` | |
| `.gitignore` already excludes `node_modules` and any `.env`, so no secrets are | |
| committed. | |
| > Push **this folder** as the repo root (so `package.json` and `render.yaml` | |
| > are at the top level). If you push the parent folder instead, set | |
| > `rootDir: saniplus-chatbot-llm` under the service in `render.yaml`. | |
| ## Step 2 β Create the service on Render | |
| **Option A β Blueprint (uses the included `render.yaml`):** | |
| 1. Render dashboard β **New** β **Blueprint**. | |
| 2. Connect your repo. Render reads `render.yaml` and proposes the service. | |
| 3. It will ask for the two secret values (they have `sync: false`): | |
| - `ANTHROPIC_API_KEY` = your `sk-ant-...` | |
| - `ACCESS_CODE` = the password you chose | |
| 4. **Apply** β first build runs `npm install` and starts `npm start`. | |
| **Option B β Manual web service:** | |
| 1. **New** β **Web Service** β connect the repo. | |
| 2. Runtime **Node**, Build `npm install`, Start `npm start`. | |
| 3. **Environment** β add `ANTHROPIC_API_KEY`, `ACCESS_CODE`, and | |
| `NODE_VERSION=20`. | |
| 4. Create. | |
| ## Step 3 β Open it | |
| Render gives you `https://saniplus-chatbot.onrender.com` (or similar). Open it, | |
| enter the access code, and the chat goes live. Share the URL **and** the code | |
| with whoever you're demoing to. | |
| --- | |
| ## Notes | |
| - **Cold start:** the free plan sleeps after ~15 min idle; the first hit then | |
| takes ~30s to wake. Upgrade to a paid instance ($7/mo) for always-on. | |
| - **Health check:** Render pings `/api/health` to confirm the service is up. | |
| - **Rotating the code:** change `ACCESS_CODE` in the Render dashboard and | |
| redeploy β existing browser sessions are revalidated on next request. | |
| - **Cost control:** the access gate keeps usage to people you share the code | |
| with. For extra safety you can still add per-IP rate limiting (ask me). | |
| - **Verify hours per branch** and complete the GDPR/HWG review before using | |
| this with real customers (see README.md). | |
| ## Protection layers (both active) | |
| - **Access code** β `ACCESS_CODE` gates `/api/chat` (401 without a valid code). | |
| - **Rate limiting** β per-IP sliding window on `/api/chat` and `/api/gate`. | |
| Defaults: 20 requests / 60s. Override with env vars `RATE_MAX` and | |
| `RATE_WINDOW_MS`. Returns HTTP 429 with `Retry-After` when exceeded. | |
| ## Always-on alternative β Fly.io (no cold start) | |
| The repo includes a `Dockerfile` + `fly.toml`. Deploy: | |
| ```powershell | |
| fly launch --no-deploy # accept the included fly.toml | |
| fly secrets set ANTHROPIC_API_KEY=sk-ant-... ACCESS_CODE=yourcode | |
| fly deploy | |
| ``` | |
| Set `min_machines_running = 1` in `fly.toml` for guaranteed always-on (no cold | |
| start). The same Docker image runs on Railway, Cloud Run, or any container host. | |