first commit

This commit is contained in:
2026-10-09 02:48:31 +07:00
commit 8db22bfaa6
17 changed files with 1722 additions and 0 deletions
+84
View File
@@ -0,0 +1,84 @@
# Deploy: stack `sicabe-host` (tanpa build)
Satu compose untuk satu host SiCABE, memuat empat service:
| Service | Image | Profile | Di host mana |
| --- | --- | --- | --- |
| `docker-socket-proxy` | `tecnativa/docker-socket-proxy` | – | **semua** host |
| `config-agent` | `<registry>/config-agent` | – | **semua** host |
| `gateway` (nginx) | `nginx:alpine` | – | **semua** host |
| `sicabe-control-panel` | `<registry>/control-panel` | `panel` | **satu** host (panel) |
Compose di sini **tidak membangun image** — semua diambil dari registry. Untuk
build & push image ke registry privat, pakai `deploy/panel/` + `scripts/build-image.sh`.
## 1. Build & push image (sekali, dari mesin dev)
```bash
./scripts/build-image.sh --all --push --registry registry.example.com/sicabe
# → registry.example.com/sicabe/control-panel:<git-sha> + :latest
# → registry.example.com/sicabe/config-agent:<git-sha> + :latest
```
`--all` membangun **panel + config-agent** dengan tag yang sama (agar satu
`SICABE_TAG` cukup di stack). Login registry dulu bila perlu: `docker login <registry>`.
## 2. Siapkan env (per host)
```bash
cd deploy/stack
cp env.example .env # isi GATEWAY_API_KEY, SICABE_REGISTRY, SICABE_DEPLOY_DIR
```
Di host **panel**, isi juga bagian bawah (`PANEL_URL`, `NEXTAUTH_SECRET`,
`KEYCLOAK_CLIENT_SECRET`, `SICABE_HOSTS`, dst).
## 3. Jalankan
```bash
# SEMUA host SiCABE (docker-proxy + config-agent + gateway):
docker compose up -d
# HANYA di host panel — sekaligus menjalankan panelnya:
docker compose --profile panel up -d
```
Cek: `docker compose ps` dan `docker compose logs -f gateway`.
## Update image
```bash
# setelah build+push tag baru:
SICABE_TAG=<tag-baru> docker compose pull # (di host panel: + --profile panel)
docker compose up -d # recreate
```
## Menghentikan / menghapus
`docker compose down` hanya menghapus service **pada profile yang aktif**. Karena
itu, di host panel jalankan dengan profile yang sama:
```bash
# host panel:
docker compose --profile panel down # hapus SEMUA (termasuk panel)
# host non-panel:
docker compose down
```
> Kalau `down` dijalankan tanpa `--profile panel` di host panel, container
> `sicabe-control-panel` akan tertinggal sebagai *orphan*. Compose akan
> memperingatkan; hapus dengan `--profile panel down` atau `docker rm -f`.
## Catatan
- **Panel memakai `network_mode: host`** karena gateway bind `127.0.0.1` (tak
terjangkau dari bridge Docker; sekaligus SAN sertifikat Trino `localhost`
cocok). Port panel = `PANEL_PORT` (default 3000).
- **Template nginx dipakai bersama** dari `../host-gateway/nginx/` (tanpa
duplikasi). Setelah mengubah template, jalankan `docker compose restart gateway`
(nginx men-substitute template saat start).
- **Menambah host baru**: jalankan `docker compose up -d` (tanpa profile) di host
itu, lalu daftarkan di panel (**Settings → Hosts & Agents**) dan **Scan**.
- Compose ini **menggantikan** `deploy/host-gateway/` + `deploy/panel/` sebagai
artefak deploy. Keduanya tetap ada untuk **build lokal**/dev.