From a7a060ec63b4eb83d3f6a293b3bff5bd12577fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kadir=20Y=C3=B6nak?= Date: Sun, 23 Aug 2026 23:20:05 +0300 Subject: [PATCH] =?UTF-8?q?chore(deploy):=20all-in-one=20compose'u=20kald?= =?UTF-8?q?=C4=B1r=20->=20proje-bazl=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit deploy/compose.yaml (surrealdb+backend+frontend+bridge all-in-one) silindi. Artık her repo kendi compose'uyla backend'in ağını paylaşır. run-stack.ps1 3 repoyu doğru sırada başlatır (backend->frontend->chatbot bridge); PODMAN-WSL-SETUP.md + ReadMe per-repo'ya güncellendi. WSL kernel/machine kurulum dokümanları korundu. --- ReadMe.md | 11 ++-- deploy/PODMAN-WSL-SETUP.md | 28 +++++---- deploy/compose.yaml | 117 ------------------------------------- deploy/run-stack.ps1 | 42 +++++++------ 4 files changed, 45 insertions(+), 153 deletions(-) delete mode 100644 deploy/compose.yaml diff --git a/ReadMe.md b/ReadMe.md index 2db38a6..c5ef6af 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -117,13 +117,14 @@ python -m src.main --evaluate # benchmark üzerinde tam metrik raporu python -m src.main --chat # etkileşimli terminal asistanı python -m src.web # geliştirici web arayüzü (http://127.0.0.1:8000) -# Podman (Docker uyumlu; motor podman) -podman compose up --build # yalnız chatbot container'ı (--validate) +# Podman (motor podman; sadece bu chatbot, tek başına) +podman compose up -d --build # izole geliştirici sohbet UI -> http://localhost:8000 ``` -**Tüm yığın (backend + frontend + chatbot) podman'da:** `deploy/PODMAN-WSL-SETUP.md` -— Windows/WSL2 için özel kernel + rootless machine kurulumu ve `deploy/compose.yaml` -ile tek komutta ayağa kaldırma (`deploy/setup-podman-wsl.ps1` + `deploy/run-stack.ps1`). +**Tüm yığın (backend + frontend + chatbot) — PROJE-BAZLI (all-in-one compose yok):** +Her repo kendi compose'uyla, backend'in ağını paylaşır. Windows/WSL2 kurulumu + +tek-komut başlatma için: `deploy/PODMAN-WSL-SETUP.md` (`deploy/setup-podman-wsl.ps1` +makineyi kurar, `deploy/run-stack.ps1` 3 repoyu doğru sırada ayağa kaldırır). ### Terminal örneği ``` diff --git a/deploy/PODMAN-WSL-SETUP.md b/deploy/PODMAN-WSL-SETUP.md index 808b2c9..737db95 100644 --- a/deploy/PODMAN-WSL-SETUP.md +++ b/deploy/PODMAN-WSL-SETUP.md @@ -75,17 +75,19 @@ wsl --shutdown & $P run --rm docker.io/surrealdb/surrealdb:v3 version # netavark hatası OLMAMALI ``` -### 3. Stack'i başlat +### 3. Stack'i başlat (PROJE-BAZLI — all-in-one compose yok) +Tek komut (base pre-pull + 3 repoyu doğru sırada başlatır): ```powershell -# docker.io anonim-pull auth hatasını önlemek için base'leri önce çek: -foreach ($i in "docker.io/library/rust:1.97-slim","docker.io/library/debian:trixie-slim", - "docker.io/library/python:3.13-slim","docker.io/oven/bun:1", - "docker.io/oven/bun:1-slim","docker.io/surrealdb/surrealdb:v3") { & $P pull $i } -# Ayağa kaldır (deploy/ içinden çalışan yollar): -& $P compose -f deploy/compose.yaml up -d --build +pwsh -File deploy/run-stack.ps1 +``` +Ya da elle (her repo kendi compose'uyla; sıra önemli — backend ağı yaratır): +```powershell +cd ..\hezarfen_backend ; & $P compose up -d --build # surrealdb + backend (:8080,:8090) +cd ..\hezarfen_frontend ; & $P compose up -d --build # frontend (:5173) +cd ..\Hezarfen-Rule-Based-Chatbot ; & $P compose --profile product up -d --build bridge # chatbot köprüsü ``` -> **Linux/macOS:** kernel/machine adımları gerekmez; sadece bu bölümü çalıştır -> (gerekirse `podman` yerine dağıtımın komutu). Portlar zaten host'a iletilir. +> 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). +> **Linux/macOS:** kernel/machine adımları gerekmez; sadece bu bölümü çalıştır. Portlar zaten host'a iletilir. --- @@ -99,10 +101,12 @@ foreach ($i in "docker.io/library/rust:1.97-slim","docker.io/library/debian:trix | build: `unable to retrieve auth token ... unauthorized` | docker.io anonim-pull dalgalanması → base imajları önce `podman pull` ile çek, sonra build. | | `Cgroups v1 not supported` | `.wslconfig`'e `kernelCommandLine = cgroup_no_v1=all` + `wsl --shutdown`. | -## Durdurma / temizlik +## Durdurma / temizlik (her repo kendi dizininde) ```powershell -& $P compose -f deploy/compose.yaml down # konteynerleri durdur (volume kalır) -& $P compose -f deploy/compose.yaml down -v # volume'ları da sil +cd ..\Hezarfen-Rule-Based-Chatbot ; & $P compose --profile product down +cd ..\hezarfen_frontend ; & $P compose down +cd ..\hezarfen_backend ; & $P compose down # volume kalır +cd ..\hezarfen_backend ; & $P compose down -v # volume'ları da sil ``` ## Notlar diff --git a/deploy/compose.yaml b/deploy/compose.yaml deleted file mode 100644 index 909a21c..0000000 --- a/deploy/compose.yaml +++ /dev/null @@ -1,117 +0,0 @@ -# Hezarfen — tüm yığını podman ile tek komutla ayağa kaldıran orkestrasyon. -# -# Bu dosya deploy/ içinden çalışır; ÜÇ repo yan yana (sibling) klonlanmış olmalı: -# / -# ├─ hezarfen_backend/ -# ├─ hezarfen_frontend/ -# └─ Hezarfen-Rule-Based-Chatbot/ <- bu repo; compose burada (deploy/) -# -# podman compose -f deploy/compose.yaml up -d --build -# (WSL2 kurulumu için: deploy/PODMAN-WSL-SETUP.md) -# -# Servisler: -# surrealdb — veritabanı (iç ağ; host'a port açmaz) -# backend — Rust API + AI köprüsü (QUIC :8090); http :8080 -# chatbot-bridge — Çelebi'yi backend'e QUIC hab/1 ile bağlayan istemci (port açmaz) -# frontend — SolidJS + Bun, :5173 (SPA + /api proxy'si backend'e) - -services: - surrealdb: - image: docker.io/surrealdb/surrealdb:v3 - container_name: hezarfen-surrealdb - user: "0" - command: - ["start", "--user", "root", "--pass", "root", "surrealkv:/data/hezarfen.db"] - volumes: - - surreal-data:/data - restart: unless-stopped - healthcheck: - test: ["CMD", "/surreal", "isready"] - interval: 10s - timeout: 5s - retries: 5 - start_period: 5s - - backend: - build: - context: ../../hezarfen_backend - dockerfile: Containerfile - image: localhost/hezarfen-backend:latest - container_name: hezarfen-backend - ports: - - "8080:8080" - - "8090:8090/udp" - environment: - HOST: 0.0.0.0 - PORT: "8080" - DB_URL: ws://surrealdb:8000 - DB_USER: root - DB_PASS: root - DB_NAMESPACE: hezarfen - DB_DATABASE: hezarfen - FILES_PATH: /data/files - RUST_LOG: info,hezarfen_backend=debug - ADMIN_USERNAME: admin - ADMIN_PASSWORD: admin123 - AI_QUIC_ADDR: 0.0.0.0:8090 - # Paylaşımlı/üretim ortamlarında MUTLAKA AI_SHARED_TOKEN ver (tahmin edilmesin). - AI_SHARED_TOKEN: ${AI_SHARED_TOKEN:-change-me} - volumes: - - hezarfen-data:/data - depends_on: - surrealdb: - condition: service_healthy - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8080/"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 10s - - chatbot-bridge: - build: - context: ../../Hezarfen-Rule-Based-Chatbot - dockerfile: Containerfile - image: localhost/hezarfen-chatbot:latest - container_name: hezarfen-chatbot-bridge - init: true - command: ["python", "-m", "src.bridge"] - environment: - AI_BRIDGE_HOST: backend - AI_BRIDGE_PORT: "8090" - AI_BACKEND_URL: http://backend:8080 - AI_SHARED_TOKEN: ${AI_SHARED_TOKEN:-change-me} - AI_TLS_SERVER_NAME: localhost - AI_SERVICE_NAME: celebi - HEZARFEN_ASSISTANT_ROLE: ogrenci - depends_on: - backend: - condition: service_healthy - restart: unless-stopped - - frontend: - build: - context: ../../hezarfen_frontend - dockerfile: Containerfile - image: localhost/hezarfen-frontend:latest - container_name: hezarfen-frontend - ports: - - "5173:5173" - environment: - PORT: "5173" - BACKEND_ORIGIN: http://backend:8080 - depends_on: - backend: - condition: service_healthy - restart: unless-stopped - healthcheck: - test: ["CMD", "bun", "-e", "fetch('http://127.0.0.1:5173/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 10s - -volumes: - hezarfen-data: - surreal-data: diff --git a/deploy/run-stack.ps1 b/deploy/run-stack.ps1 index 5db4bf6..77e28a6 100644 --- a/deploy/run-stack.ps1 +++ b/deploy/run-stack.ps1 @@ -1,7 +1,7 @@ -# Hezarfen — Podman stack'i ayağa kaldırır. -# 1) Tüm Containerfile base imajlarını pre-pull eder (docker.io anonim-pull auth -# hatalarını build sırasında yaşamamak için). -# 2) podman compose up -d --build. +# Hezarfen — Podman stack'i PROJE-BAZLI ayağa kaldırır (all-in-one compose YOK). +# 1) Base imajları pre-pull (docker.io anonim-pull auth hatalarını önlemek için). +# 2) Her repoyu kendi compose'uyla, doğru sırada başlatır: +# hezarfen_backend (db+backend, ağı yaratır) -> hezarfen_frontend -> chatbot bridge # 3) Doğrular ve localhost adreslerini basar. # Ön koşul: deploy/setup-podman-wsl.ps1 bir kez çalıştırılmış olmalı. # Çalıştır: pwsh -File deploy/run-stack.ps1 @@ -17,34 +17,38 @@ function Find-Podman { throw "podman.exe bulunamadı." } $PODMAN = Find-Podman -$compose = Join-Path $PSScriptRoot "compose.yaml" -$parent = Resolve-Path (Join-Path $PSScriptRoot "..\..") +$parent = Resolve-Path (Join-Path $PSScriptRoot "..\..") +$backend = Join-Path $parent "hezarfen_backend" +$frontend = Join-Path $parent "hezarfen_frontend" +$chatbot = Join-Path $parent "Hezarfen-Rule-Based-Chatbot" & $PODMAN machine start *> $null 2>&1 Write-Host "[1/3] Base imajlar pre-pull ediliyor..." -$cfiles = @( - (Join-Path $parent "hezarfen_backend\Containerfile"), - (Join-Path $parent "hezarfen_frontend\Containerfile"), - (Join-Path $parent "Hezarfen-Rule-Based-Chatbot\Containerfile") -) $bases = @("docker.io/surrealdb/surrealdb:v3") -foreach ($cf in $cfiles) { +foreach ($cf in @((Join-Path $backend "Containerfile"), + (Join-Path $frontend "Containerfile"), + (Join-Path $chatbot "Containerfile"))) { if (Test-Path $cf) { Select-String -Path $cf -Pattern '^\s*FROM\s+(\S+)' | ForEach-Object { $bases += $_.Matches[0].Groups[1].Value } } } -$bases = $bases | Sort-Object -Unique -foreach ($img in $bases) { - Write-Host " pull $img" - & $PODMAN pull $img *> $null 2>&1 +foreach ($img in ($bases | Sort-Object -Unique)) { + Write-Host " pull $img"; & $PODMAN pull $img *> $null 2>&1 } -Write-Host "`n[2/3] podman compose up -d --build (backend Rust ilk seferde uzun sürer)..." -& $PODMAN compose -f $compose up -d --build -if ($LASTEXITCODE -ne 0) { throw "compose up başarısız (build log'una bak)." } +Write-Host "`n[2/3] Proje-bazlı up (backend Rust ilk seferde uzun sürer)..." +function Compose-Up([string]$dir, [string[]]$extra) { + Push-Location $dir + try { & $PODMAN compose @extra up -d --build; if ($LASTEXITCODE -ne 0) { throw "compose up başarısız: $dir" } } + finally { Pop-Location } +} +Compose-Up $backend @() # ağı (hezarfen_backend_default) yaratır +Compose-Up $frontend @() # backend ağına bağlanır +Compose-Up $chatbot @("--profile", "product") # bridge; backend ağına dial-in eder +# (Not: chatbot'u backend'siz TEK BAŞINA denemek için: cd $chatbot; podman compose up -d -> :8000) Write-Host "`n[3/3] Doğrulama..." Start-Sleep -Seconds 6