All-in-one compose'u kaldır -> proje-bazlı
Browse files at this commita7a060ec63b4eb83d3f6a293b3bff5bd12577fa8Parent: 2612c19- chore
- all-in-one compose'u kaldır -> proje-bazlı
4 changed files +45 -153
- ReadMe.md +6 -5
- deploy/PODMAN-WSL-SETUP.md +16 -12
- deploy/compose.yaml +0 -117
- deploy/run-stack.ps1 +23 -19
ReadMe.mdmodified+6 -5
| @@ -117,13 +117,14 @@ python -m src.main --evaluate # benchmark üzerinde tam metrik raporu | |||
| 117 | python -m src.main --chat # etkileşimli terminal asistanı | 117 | python -m src.main --chat # etkileşimli terminal asistanı |
| 118 | python -m src.web # geliştirici web arayüzü (http://127.0.0.1:8000) | 118 | python -m src.web # geliştirici web arayüzü (http://127.0.0.1:8000) |
| 119 | 119 | ||
| 120 | -# Podman (Docker uyumlu; motor podman) | 120 | +# Podman (motor podman; sadece bu chatbot, tek başına) |
| 121 | -podman compose up --build # yalnız chatbot container'ı (--validate) | 121 | +podman compose up -d --build # izole geliştirici sohbet UI -> http://localhost:8000 |
| 122 | ``` | 122 | ``` |
| 123 | 123 | ||
| 124 | -**Tüm yığın (backend + frontend + chatbot) podman'da:** `deploy/PODMAN-WSL-SETUP.md` | 124 | +**Tüm yığın (backend + frontend + chatbot) — PROJE-BAZLI (all-in-one compose yok):** |
| 125 | -— Windows/WSL2 için özel kernel + rootless machine kurulumu ve `deploy/compose.yaml` | 125 | +Her repo kendi compose'uyla, backend'in ağını paylaşır. Windows/WSL2 kurulumu + |
| 126 | -ile tek komutta ayağa kaldırma (`deploy/setup-podman-wsl.ps1` + `deploy/run-stack.ps1`). | 126 | +tek-komut başlatma için: `deploy/PODMAN-WSL-SETUP.md` (`deploy/setup-podman-wsl.ps1` |
| 127 | +makineyi kurar, `deploy/run-stack.ps1` 3 repoyu doğru sırada ayağa kaldırır). | ||
| 127 | 128 | ||
| 128 | ### Terminal örneği | 129 | ### Terminal örneği |
| 129 | ``` | 130 | ``` |
deploy/PODMAN-WSL-SETUP.mdmodified+16 -12
| @@ -75,17 +75,19 @@ wsl --shutdown | |||
| 75 | & $P run --rm docker.io/surrealdb/surrealdb:v3 version # netavark hatası OLMAMALI | 75 | & $P run --rm docker.io/surrealdb/surrealdb:v3 version # netavark hatası OLMAMALI |
| 76 | ``` | 76 | ``` |
| 77 | 77 | ||
| 78 | -### 3. Stack'i başlat | 78 | +### 3. Stack'i başlat (PROJE-BAZLI — all-in-one compose yok) |
| 79 | +Tek komut (base pre-pull + 3 repoyu doğru sırada başlatır): | ||
| 79 | ```powershell | 80 | ```powershell |
| 80 | -# docker.io anonim-pull auth hatasını önlemek için base'leri önce çek: | 81 | +pwsh -File deploy/run-stack.ps1 |
| 81 | -foreach ($i in "docker.io/library/rust:1.97-slim","docker.io/library/debian:trixie-slim", | 82 | +``` |
| 82 | - "docker.io/library/python:3.13-slim","docker.io/oven/bun:1", | 83 | +Ya da elle (her repo kendi compose'uyla; sıra önemli — backend ağı yaratır): |
| 83 | - "docker.io/oven/bun:1-slim","docker.io/surrealdb/surrealdb:v3") { & $P pull $i } | 84 | +```powershell |
| 84 | -# Ayağa kaldır (deploy/ içinden çalışan yollar): | 85 | +cd ..\hezarfen_backend ; & $P compose up -d --build # surrealdb + backend (:8080,:8090) |
| 85 | -& $P compose -f deploy/compose.yaml up -d --build | 86 | +cd ..\hezarfen_frontend ; & $P compose up -d --build # frontend (:5173) |
| 87 | +cd ..\Hezarfen-Rule-Based-Chatbot ; & $P compose --profile product up -d --build bridge # chatbot köprüsü | ||
| 86 | ``` | 88 | ``` |
| 87 | -> **Linux/macOS:** kernel/machine adımları gerekmez; sadece bu bölümü çalıştır | 89 | +> Chatbot'u backend'siz **tek başına** denemek için: `cd Hezarfen-Rule-Based-Chatbot; & $P compose up -d` → `http://localhost:8000` (izole dev sohbet UI). |
| 88 | -> (gerekirse `podman` yerine dağıtımın komutu). Portlar zaten host'a iletilir. | 90 | +> **Linux/macOS:** kernel/machine adımları gerekmez; sadece bu bölümü çalıştır. Portlar zaten host'a iletilir. |
| 89 | 91 | ||
| 90 | --- | 92 | --- |
| 91 | 93 | ||
| @@ -99,10 +101,12 @@ foreach ($i in "docker.io/library/rust:1.97-slim","docker.io/library/debian:trix | |||
| 99 | | build: `unable to retrieve auth token ... unauthorized` | docker.io anonim-pull dalgalanması → base imajları önce `podman pull` ile çek, sonra build. | | 101 | | build: `unable to retrieve auth token ... unauthorized` | docker.io anonim-pull dalgalanması → base imajları önce `podman pull` ile çek, sonra build. | |
| 100 | | `Cgroups v1 not supported` | `.wslconfig`'e `kernelCommandLine = cgroup_no_v1=all` + `wsl --shutdown`. | | 102 | | `Cgroups v1 not supported` | `.wslconfig`'e `kernelCommandLine = cgroup_no_v1=all` + `wsl --shutdown`. | |
| 101 | 103 | ||
| 102 | -## Durdurma / temizlik | 104 | +## Durdurma / temizlik (her repo kendi dizininde) |
| 103 | ```powershell | 105 | ```powershell |
| 104 | -& $P compose -f deploy/compose.yaml down # konteynerleri durdur (volume kalır) | 106 | +cd ..\Hezarfen-Rule-Based-Chatbot ; & $P compose --profile product down |
| 105 | -& $P compose -f deploy/compose.yaml down -v # volume'ları da sil | 107 | +cd ..\hezarfen_frontend ; & $P compose down |
| 108 | +cd ..\hezarfen_backend ; & $P compose down # volume kalır | ||
| 109 | +cd ..\hezarfen_backend ; & $P compose down -v # volume'ları da sil | ||
| 106 | ``` | 110 | ``` |
| 107 | 111 | ||
| 108 | ## Notlar | 112 | ## Notlar |
deploy/compose.yamldeleted+0 -117
| @@ -1,117 +0,0 @@ | |||
| 1 | -# Hezarfen — tüm yığını podman ile tek komutla ayağa kaldıran orkestrasyon. | ||
| 2 | -# | ||
| 3 | -# Bu dosya deploy/ içinden çalışır; ÜÇ repo yan yana (sibling) klonlanmış olmalı: | ||
| 4 | -# <parent>/ | ||
| 5 | -# ├─ hezarfen_backend/ | ||
| 6 | -# ├─ hezarfen_frontend/ | ||
| 7 | -# └─ Hezarfen-Rule-Based-Chatbot/ <- bu repo; compose burada (deploy/) | ||
| 8 | -# | ||
| 9 | -# podman compose -f deploy/compose.yaml up -d --build | ||
| 10 | -# (WSL2 kurulumu için: deploy/PODMAN-WSL-SETUP.md) | ||
| 11 | -# | ||
| 12 | -# Servisler: | ||
| 13 | -# surrealdb — veritabanı (iç ağ; host'a port açmaz) | ||
| 14 | -# backend — Rust API + AI köprüsü (QUIC :8090); http :8080 | ||
| 15 | -# chatbot-bridge — Çelebi'yi backend'e QUIC hab/1 ile bağlayan istemci (port açmaz) | ||
| 16 | -# frontend — SolidJS + Bun, :5173 (SPA + /api proxy'si backend'e) | ||
| 17 | - | ||
| 18 | -services: | ||
| 19 | - surrealdb: | ||
| 20 | - image: docker.io/surrealdb/surrealdb:v3 | ||
| 21 | - container_name: hezarfen-surrealdb | ||
| 22 | - user: "0" | ||
| 23 | - command: | ||
| 24 | - ["start", "--user", "root", "--pass", "root", "surrealkv:/data/hezarfen.db"] | ||
| 25 | - volumes: | ||
| 26 | - - surreal-data:/data | ||
| 27 | - restart: unless-stopped | ||
| 28 | - healthcheck: | ||
| 29 | - test: ["CMD", "/surreal", "isready"] | ||
| 30 | - interval: 10s | ||
| 31 | - timeout: 5s | ||
| 32 | - retries: 5 | ||
| 33 | - start_period: 5s | ||
| 34 | - | ||
| 35 | - backend: | ||
| 36 | - build: | ||
| 37 | - context: ../../hezarfen_backend | ||
| 38 | - dockerfile: Containerfile | ||
| 39 | - image: localhost/hezarfen-backend:latest | ||
| 40 | - container_name: hezarfen-backend | ||
| 41 | - ports: | ||
| 42 | - - "8080:8080" | ||
| 43 | - - "8090:8090/udp" | ||
| 44 | - environment: | ||
| 45 | - HOST: 0.0.0.0 | ||
| 46 | - PORT: "8080" | ||
| 47 | - DB_URL: ws://surrealdb:8000 | ||
| 48 | - DB_USER: root | ||
| 49 | - DB_PASS: root | ||
| 50 | - DB_NAMESPACE: hezarfen | ||
| 51 | - DB_DATABASE: hezarfen | ||
| 52 | - FILES_PATH: /data/files | ||
| 53 | - RUST_LOG: info,hezarfen_backend=debug | ||
| 54 | - ADMIN_USERNAME: admin | ||
| 55 | - ADMIN_PASSWORD: admin123 | ||
| 56 | - AI_QUIC_ADDR: 0.0.0.0:8090 | ||
| 57 | - # Paylaşımlı/üretim ortamlarında MUTLAKA AI_SHARED_TOKEN ver (tahmin edilmesin). | ||
| 58 | - AI_SHARED_TOKEN: ${AI_SHARED_TOKEN:-change-me} | ||
| 59 | - volumes: | ||
| 60 | - - hezarfen-data:/data | ||
| 61 | - depends_on: | ||
| 62 | - surrealdb: | ||
| 63 | - condition: service_healthy | ||
| 64 | - restart: unless-stopped | ||
| 65 | - healthcheck: | ||
| 66 | - test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8080/"] | ||
| 67 | - interval: 30s | ||
| 68 | - timeout: 5s | ||
| 69 | - retries: 3 | ||
| 70 | - start_period: 10s | ||
| 71 | - | ||
| 72 | - chatbot-bridge: | ||
| 73 | - build: | ||
| 74 | - context: ../../Hezarfen-Rule-Based-Chatbot | ||
| 75 | - dockerfile: Containerfile | ||
| 76 | - image: localhost/hezarfen-chatbot:latest | ||
| 77 | - container_name: hezarfen-chatbot-bridge | ||
| 78 | - init: true | ||
| 79 | - command: ["python", "-m", "src.bridge"] | ||
| 80 | - environment: | ||
| 81 | - AI_BRIDGE_HOST: backend | ||
| 82 | - AI_BRIDGE_PORT: "8090" | ||
| 83 | - AI_BACKEND_URL: http://backend:8080 | ||
| 84 | - AI_SHARED_TOKEN: ${AI_SHARED_TOKEN:-change-me} | ||
| 85 | - AI_TLS_SERVER_NAME: localhost | ||
| 86 | - AI_SERVICE_NAME: celebi | ||
| 87 | - HEZARFEN_ASSISTANT_ROLE: ogrenci | ||
| 88 | - depends_on: | ||
| 89 | - backend: | ||
| 90 | - condition: service_healthy | ||
| 91 | - restart: unless-stopped | ||
| 92 | - | ||
| 93 | - frontend: | ||
| 94 | - build: | ||
| 95 | - context: ../../hezarfen_frontend | ||
| 96 | - dockerfile: Containerfile | ||
| 97 | - image: localhost/hezarfen-frontend:latest | ||
| 98 | - container_name: hezarfen-frontend | ||
| 99 | - ports: | ||
| 100 | - - "5173:5173" | ||
| 101 | - environment: | ||
| 102 | - PORT: "5173" | ||
| 103 | - BACKEND_ORIGIN: http://backend:8080 | ||
| 104 | - depends_on: | ||
| 105 | - backend: | ||
| 106 | - condition: service_healthy | ||
| 107 | - restart: unless-stopped | ||
| 108 | - healthcheck: | ||
| 109 | - test: ["CMD", "bun", "-e", "fetch('http://127.0.0.1:5173/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"] | ||
| 110 | - interval: 30s | ||
| 111 | - timeout: 5s | ||
| 112 | - retries: 3 | ||
| 113 | - start_period: 10s | ||
| 114 | - | ||
| 115 | -volumes: | ||
| 116 | - hezarfen-data: | ||
| 117 | - surreal-data: | ||
deploy/run-stack.ps1modified+23 -19
| @@ -1,7 +1,7 @@ | |||
| 1 | -# Hezarfen — Podman stack'i ayağa kaldırır. | 1 | +# Hezarfen — Podman stack'i PROJE-BAZLI ayağa kaldırır (all-in-one compose YOK). |
| 2 | -# 1) Tüm Containerfile base imajlarını pre-pull eder (docker.io anonim-pull auth | 2 | +# 1) Base imajları pre-pull (docker.io anonim-pull auth hatalarını önlemek için). |
| 3 | -# hatalarını build sırasında yaşamamak için). | 3 | +# 2) Her repoyu kendi compose'uyla, doğru sırada başlatır: |
| 4 | -# 2) podman compose up -d --build. | 4 | +# hezarfen_backend (db+backend, ağı yaratır) -> hezarfen_frontend -> chatbot bridge |
| 5 | # 3) Doğrular ve localhost adreslerini basar. | 5 | # 3) Doğrular ve localhost adreslerini basar. |
| 6 | # Ön koşul: deploy/setup-podman-wsl.ps1 bir kez çalıştırılmış olmalı. | 6 | # Ön koşul: deploy/setup-podman-wsl.ps1 bir kez çalıştırılmış olmalı. |
| 7 | # Çalıştır: pwsh -File deploy/run-stack.ps1 | 7 | # Çalıştır: pwsh -File deploy/run-stack.ps1 |
| @@ -17,34 +17,38 @@ function Find-Podman { | |||
| 17 | throw "podman.exe bulunamadı." | 17 | throw "podman.exe bulunamadı." |
| 18 | } | 18 | } |
| 19 | $PODMAN = Find-Podman | 19 | $PODMAN = Find-Podman |
| 20 | -$compose = Join-Path $PSScriptRoot "compose.yaml" | 20 | +$parent = Resolve-Path (Join-Path $PSScriptRoot "..\..") |
| 21 | -$parent = Resolve-Path (Join-Path $PSScriptRoot "..\..") | 21 | +$backend = Join-Path $parent "hezarfen_backend" |
| 22 | +$frontend = Join-Path $parent "hezarfen_frontend" | ||
| 23 | +$chatbot = Join-Path $parent "Hezarfen-Rule-Based-Chatbot" | ||
| 22 | 24 | ||
| 23 | & $PODMAN machine start *> $null 2>&1 | 25 | & $PODMAN machine start *> $null 2>&1 |
| 24 | 26 | ||
| 25 | Write-Host "[1/3] Base imajlar pre-pull ediliyor..." | 27 | Write-Host "[1/3] Base imajlar pre-pull ediliyor..." |
| 26 | -$cfiles = @( | ||
| 27 | - (Join-Path $parent "hezarfen_backend\Containerfile"), | ||
| 28 | - (Join-Path $parent "hezarfen_frontend\Containerfile"), | ||
| 29 | - (Join-Path $parent "Hezarfen-Rule-Based-Chatbot\Containerfile") | ||
| 30 | -) | ||
| 31 | $bases = @("docker.io/surrealdb/surrealdb:v3") | 28 | $bases = @("docker.io/surrealdb/surrealdb:v3") |
| 32 | -foreach ($cf in $cfiles) { | 29 | +foreach ($cf in @((Join-Path $backend "Containerfile"), |
| 30 | + (Join-Path $frontend "Containerfile"), | ||
| 31 | + (Join-Path $chatbot "Containerfile"))) { | ||
| 33 | if (Test-Path $cf) { | 32 | if (Test-Path $cf) { |
| 34 | Select-String -Path $cf -Pattern '^\s*FROM\s+(\S+)' | ForEach-Object { | 33 | Select-String -Path $cf -Pattern '^\s*FROM\s+(\S+)' | ForEach-Object { |
| 35 | $bases += $_.Matches[0].Groups[1].Value | 34 | $bases += $_.Matches[0].Groups[1].Value |
| 36 | } | 35 | } |
| 37 | } | 36 | } |
| 38 | } | 37 | } |
| 39 | -$bases = $bases | Sort-Object -Unique | 38 | +foreach ($img in ($bases | Sort-Object -Unique)) { |
| 40 | -foreach ($img in $bases) { | 39 | + Write-Host " pull $img"; & $PODMAN pull $img *> $null 2>&1 |
| 41 | - Write-Host " pull $img" | ||
| 42 | - & $PODMAN pull $img *> $null 2>&1 | ||
| 43 | } | 40 | } |
| 44 | 41 | ||
| 45 | -Write-Host "`n[2/3] podman compose up -d --build (backend Rust ilk seferde uzun sürer)..." | 42 | +Write-Host "`n[2/3] Proje-bazlı up (backend Rust ilk seferde uzun sürer)..." |
| 46 | -& $PODMAN compose -f $compose up -d --build | 43 | +function Compose-Up([string]$dir, [string[]]$extra) { |
| 47 | -if ($LASTEXITCODE -ne 0) { throw "compose up başarısız (build log'una bak)." } | 44 | + Push-Location $dir |
| 45 | + try { & $PODMAN compose @extra up -d --build; if ($LASTEXITCODE -ne 0) { throw "compose up başarısız: $dir" } } | ||
| 46 | + finally { Pop-Location } | ||
| 47 | +} | ||
| 48 | +Compose-Up $backend @() # ağı (hezarfen_backend_default) yaratır | ||
| 49 | +Compose-Up $frontend @() # backend ağına bağlanır | ||
| 50 | +Compose-Up $chatbot @("--profile", "product") # bridge; backend ağına dial-in eder | ||
| 51 | +# (Not: chatbot'u backend'siz TEK BAŞINA denemek için: cd $chatbot; podman compose up -d -> :8000) | ||
| 48 | 52 | ||
| 49 | Write-Host "`n[3/3] Doğrulama..." | 53 | Write-Host "`n[3/3] Doğrulama..." |
| 50 | Start-Sleep -Seconds 6 | 54 | Start-Sleep -Seconds 6 |