selfapi-v2 / SETUP.md
akashyadav758
Harden monitor (gate all routes), swap ChatGPT backend to free-Chatgpt-api, clean repo
5c7f4b5
|
Raw
History Blame Contribute Delete
2.52 kB
# Setup β€” Deploy with Docker (self-host)
Very short guide. Runs the browser + all 3 API servers on your own machine/server.
**Your login is saved automatically β€” no database needed for Docker.**
## 1. Install Docker
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (Mac/Windows) or `docker` + `docker compose` (Linux).
- Check: `docker --version`
## 2. Get the code
```bash
git clone https://huggingface.co/spaces/akash1313/selfapi-v2
cd selfapi-v2
```
## 3. Run it
```bash
docker compose up --build -d
```
- Open **http://localhost:3001** β†’ watch the browser.
- **Log in** to ChatGPT / Gemini / Flow once.
## 4. Stop / restart
```bash
docker compose down # stops; login stays saved in the volume
docker compose up -d # starts again; login is back
```
Your profile lives in the `chrome-profile` Docker volume, so logins survive
restarts and reboots automatically. (To wipe it: `docker compose down -v`.)
---
## Which file does what
| File | Job |
|------|-----|
| `docker-compose.yml` | Runs everything (browser + 3 servers) + the save-login volume |
| `Dockerfile` | Builds the browser image |
| `start_hf.sh` | Boot steps (start Chrome + extensions) |
---
## Running on Hugging Face instead? (needs Neon)
HF free Spaces have **no permanent disk**, so there logins need a Postgres database.
1. Sign up free at **[neon.tech](https://neon.tech)** β†’ create a project.
2. Copy the **connection string**
(`postgresql://user:pass@...neon.tech/db?sslmode=require`).
3. In your Space β†’ **Settings β†’ Variables and secrets β†’ New secret**:
- Name: `DATABASE_URL`
- Value: the connection string
4. The Space restarts β†’ **log in once** β†’ it auto-saves every 5 min and survives rebuilds.
> Deploy code to HF with `git push`. Never commit the connection string.
---
## Using the API
All three servers run inside the container; the monitor fronts them on one URL by path:
| Service | Base path | Example |
|---------|-----------|---------|
| ChatGPT | `/gpt/` | `POST /gpt/api/chat` |
| Gemini | `/gemini/` | `POST /gemini/chat` |
| Flow | `/flow/` | `POST /flow/generate/video` |
**Set an `API_KEY` secret** (HF: Settings β†’ secret `API_KEY`; Docker: add to `.env`) β€” every API
call must send it:
```bash
curl -X POST https://YOUR-SPACE.hf.space/gpt/api/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message":"hello"}'
```
Without the key the API returns `401`/`503`. The monitor UI stays open (no key).