Spaces:
Sleeping

vela-app / docs /tutorials /02-deploy-docker-render.md
fahmialfayadh
feat(add docs): add /docs url yang menampilkan docs projek ini
33cda0a
|
Raw History Blame Contribute Delete
3.97 kB
# Tutorial 2: Deployment via Docker & Render.com
> **Tujuan tutorial ini**: Menjalankan Vela Personal AI Ecosystem sebagai container Docker di VPS sendiri, atau secara gratis (free tier) di cloud Render.com.
---
## Opsi A: Deployment Container Docker
### 1. Build Image
Dari root repository:
```bash
docker build -t personal-ai-ecosystem:latest .
```
**Yang dilakukan `Dockerfile`**:
1. Base image `python:3.11-slim`.
2. Install dependensi sistem: `git`, `ripgrep`, `procps`, `curl`, `nodejs`, `npm` (dibutuhkan Hermes Agent & WhatsApp bridge).
3. Install package Python dari `requirements.txt`.
4. Install Hermes Agent Core CLI langsung dari repository resmi.
5. Menyalin sesi WhatsApp yang sudah di-pairing (`whatsapp_session/`) ke `/root/.hermes/whatsapp/session/`.
6. Memasang `config.cloud.yaml` sebagai `/root/.hermes/config.yaml` (MCP servers: gym-tracker + classroom).
### 2. Run Container dengan Persistent Volume
```bash
docker run -d \
--name ecosystem_app \
-p 8787:8787 \
-e HERMES_DASH_TOKEN="gymku123" \
-e HERMES_DASH_HOST="0.0.0.0" \
-e OPENROUTER_API_KEY="sk-or-v1-your_key" \
-e GITHUB_TOKEN="ghp_your_token" \
-v ~/.hermes:/root/.hermes \
--restart unless-stopped \
personal-ai-ecosystem:latest
```
> [!IMPORTANT]
> Volume `-v ~/.hermes:/root/.hermes` wajib dipasang agar database SQLite (`audit.db`, `chat_history.db`, `habits.db`) dan token OAuth tidak hilang saat container di-restart.
Akses di **`http://<IP-server>:8787`**.
---
## Opsi B: Deployment Cloud Gratis di Render.com
Repository sudah menyertakan Blueprint `render.yaml`, sehingga deploy bisa satu klik:
1. Push repository ini ke GitHub.
2. Di [Render Dashboard](https://dashboard.render.com), pilih **New → Blueprint**, lalu hubungkan repository.
3. Render akan membaca `render.yaml` dan membuat Web Service bernama `personal-ai-ecosystem`:
- Environment: **Docker**
- Region: **Singapore**
- Plan: **Free**
4. Isi environment variables:
**Non-secret (sudah otomatis dari `render.yaml`):**
| Variabel | Nilai |
| :--- | :--- |
| `HERMES_DASH_HOST` | `0.0.0.0` |
| `WHATSAPP_ENABLED` | `true` |
| `WHATSAPP_ALLOWED_USERS` | nomor WA yang diizinkan |
| `WEATHER_LAT` / `WEATHER_LON` / `WEATHER_CITY` | koordinat & nama kota |
**Secret (isi manual di dashboard Render — tidak disimpan di repo):**
| Variabel | Fungsi |
| :--- | :--- |
| `HERMES_DASH_TOKEN` | token login dashboard |
| `OPENROUTER_API_KEY` | API key LLM |
| `GITHUB_TOKEN` | PAT GitHub untuk panel Dev Activity |
| `HERMES_CUSTOM_API_GROQ_COM_API_KEY` | API key provider alternatif |
5. Klik **Apply** — Render akan build image dari `Dockerfile` dan men-deploy otomatis di region Singapore.
---
## Verifikasi Setelah Deploy
1. Buka URL publik yang diberikan (Render) atau `http://<host>:8787` (VPS).
2. Login dengan token dashboard.
3. Cek `GET /api/config` untuk memastikan model & status autentikasi benar.
4. Kirim chat test di AI Command Hub.
---
## Troubleshooting
| Gejala | Penyebab | Solusi |
| :--- | :--- | :--- |
| Container mati setelah beberapa detik | Port/handshake belum siap | Pastikan `HERMES_DASH_HOST=0.0.0.0` dan `PORT=8787` diset |
| WhatsApp tidak merespons | Sesi Baileys belum ter-copy / node hilang | Pastikan `whatsapp_session/` berisi kredensial valid; Dockerfile sudah menginstall Node.js |
| Data hilang setelah redeploy | Persistent volume tidak dipasang | Pasang volume `/root/.hermes` atau gunakan auto-sync Supabase (lihat [Tutorial 3](./03-deploy-huggingface.md)) |
---
## Langkah Selanjutnya
- Deploy dengan akselerasi GPU gratis: [Tutorial 3 — Hugging Face Spaces](./03-deploy-huggingface.md)
- Expose server lokal ke internet tanpa deploy: jalankan Cloudflare Tunnel:
```bash
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared.deb
cloudflared tunnel --url http://localhost:8787
```