Spaces:
Sleeping

File size: 3,974 Bytes
33cda0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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
```