diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..36802d6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +containers/odoo/deb/*.deb filter=lfs diff=lfs merge=lfs -text diff --git a/BadAI/badai b/BadAI/badai deleted file mode 100644 index 716dced..0000000 --- a/BadAI/badai +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash -# BadAI command-line tool -# Usage: badai restart [--sleep N] - -set -e # Exit on error - -sleep_time=3 # Default sleep time in seconds - -# Parse arguments -if [[ "$1" == "restart" ]]; then - name="" - if [[ "$2" == "--sleep" && -n "$3" && "$3" =~ ^[0-9]+$ ]]; then - sleep_time="$3" - name="$4" - elif [[ -n "$2" ]]; then - name="$2" - fi - - echo "Reloading systemd user daemon..." - systemctl --user daemon-reload - - if [[ -n "$name" ]]; then - # Riavvia servizio specifico - # Cerca container - container_file="" - for file in ~/.config/containers/systemd/*.container; do - if [[ -f "$file" ]]; then - if [[ "$(basename "$file")" =~ ^99_ ]]; then continue; fi - service_name=$(basename "$file" .container) - display_name=$(echo "$service_name" | sed 's/^[0-9]*_//') - if [[ "$display_name" == "$name" ]]; then - container_file="$file" - break - fi - fi - done - if [[ -n "$container_file" ]]; then - service_name=$(basename "$container_file" .container) - echo "Restarting container $name..." - if systemctl --user restart "$service_name" 2>/dev/null; then - echo " ✓ $name restarted successfully" - else - echo " ✗ Failed to restart $name" - fi - else - # Cerca network - network_file="" - for file in ~/.config/containers/systemd/*.network; do - if [[ -f "$file" ]]; then - if [[ "$(basename "$file")" =~ ^99_ ]]; then continue; fi - service_name=$(basename "$file" .network)-network - display_name=$(echo "$service_name" | sed 's/^[0-9]*_//') - if [[ "$display_name" == "$name" ]]; then - network_file="$file" - break - fi - fi - done - if [[ -n "$network_file" ]]; then - service_name=$(basename "$network_file" .network)-network - echo "Restarting network $name..." - if systemctl --user try-restart "$service_name" 2>/dev/null || systemctl --user start "$service_name" 2>/dev/null; then - echo " ✓ $name restarted successfully" - else - echo " ✗ Failed to restart $name" - fi - else - echo "Service $name not found." - exit 1 - fi - fi - # Riavvia nginx - nginx_file="" - for file in ~/.config/containers/systemd/*nginx*.container; do - if [[ -f "$file" ]]; then - nginx_file="$file" - break - fi - done - if [[ -n "$nginx_file" ]]; then - service_name=$(basename "$nginx_file" .container) - echo "Restarting nginx..." - if systemctl --user restart "$service_name" 2>/dev/null; then - echo " ✓ nginx restarted successfully" - else - echo " ✗ Failed to restart nginx" - fi - fi - else - # Riavvia tutti - echo "Restarting all quadlet networks..." - for file in ~/.config/containers/systemd/*.network; do - if [[ -f "$file" ]]; then - if [[ "$(basename "$file")" =~ ^99_ ]]; then continue; fi - service_name=$(basename "$file" .network)-network - display_name=$(echo "$service_name" | sed 's/^[0-9]*_//') - echo "Restarting $display_name..." - if systemctl --user try-restart "$service_name" 2>/dev/null || systemctl --user start "$service_name" 2>/dev/null; then - echo " ✓ $display_name restarted successfully" - else - echo " ✗ Failed to restart $display_name" - fi - sleep "$sleep_time" - fi - done - - echo "Restarting all quadlet containers..." - for file in ~/.config/containers/systemd/*.container; do - if [[ -f "$file" ]]; then - if [[ "$(basename "$file")" =~ ^99_ ]]; then continue; fi - service_name=$(basename "$file" .container) - display_name=$(echo "$service_name" | sed 's/^[0-9]*_//') - echo "Restarting $display_name..." - if systemctl --user restart "$service_name" 2>/dev/null; then - echo " ✓ $display_name restarted successfully" - else - echo " ✗ Failed to restart $display_name" - fi - sleep "$sleep_time" - fi - done - - echo "All services restarted successfully." - fi -elif [[ "$1" == "help" || -z "$1" ]]; then - cat <<'EOF' -B A D A I - C O M M A N D L I N E --------------------------------------------------------------------------------- - -Usage: badai [options] - -Commands: - restart [--sleep N] [name] Restart all quadlet containers and networks, or a specific one by name (without prefix), reload systemd user daemon - help Show this help message - -Options: - --sleep N Sleep N seconds between restarts (default: 3) -EOF -else - echo "Unknown command: $1" - echo "Use 'badai help' for usage." -fi \ No newline at end of file diff --git a/BadAI/badai.go b/BadAI/badai.go deleted file mode 100644 index 25f58d9..0000000 --- a/BadAI/badai.go +++ /dev/null @@ -1,213 +0,0 @@ -package main - -import ( - "fmt" - "os" - "os/exec" - "path/filepath" - "regexp" - "strconv" - "strings" - "time" -) - -func main() { - if len(os.Args) < 2 { - printHelp() - return - } - - command := os.Args[1] - - switch command { - case "restart": - name := "" - if len(os.Args) > 2 { - if os.Args[2] == "--sleep" && len(os.Args) > 3 { - // Ignora per ora, ma in handleRestart parsare - } else { - name = os.Args[2] - } - } - handleRestart(name) - case "help": - printHelp() - default: - fmt.Printf("Unknown command: %s\n", command) - fmt.Println("Use 'duckai help' for usage.") - os.Exit(1) - } -} - -func handleRestart(name string) { - sleepTime := 3 - args := os.Args[2:] - if len(args) > 0 && args[0] == "--sleep" && len(args) > 1 { - if s, err := strconv.Atoi(args[1]); err == nil { - sleepTime = s - } - if len(args) > 2 { - name = args[2] - } - } else if name == "" && len(args) > 0 { - name = args[0] - } - - fmt.Println("Reloading systemd user daemon...") - runCommand("systemctl", "--user", "daemon-reload") - - if name != "" { - // Riavvia servizio specifico - containerFile := findServiceFile("*.container", name) - if containerFile != "" { - serviceName := strings.TrimSuffix(filepath.Base(containerFile), ".container") - fmt.Printf("Restarting container %s...\n", name) - if runCommand("systemctl", "--user", "restart", serviceName) { - fmt.Printf(" ✓ %s restarted successfully\n", name) - } else { - fmt.Printf(" ✗ Failed to restart %s\n", name) - } - } else { - networkFile := findServiceFile("*.network", name) - if networkFile != "" { - serviceName := strings.TrimSuffix(filepath.Base(networkFile), ".network") + "-network" - fmt.Printf("Restarting network %s...\n", name) - if runCommand("systemctl", "--user", "try-restart", serviceName) || runCommand("systemctl", "--user", "start", serviceName) { - fmt.Printf(" ✓ %s restarted successfully\n", name) - } else { - fmt.Printf(" ✗ Failed to restart %s\n", name) - } - } else { - fmt.Printf("Service %s not found.\n", name) - os.Exit(1) - } - } - // Riavvia nginx - restartNginx() - } else { - fmt.Println("Restarting all quadlet networks...") - restartNetworks(sleepTime) - - fmt.Println("Restarting all quadlet containers...") - restartContainers(sleepTime) - - fmt.Println("All services restarted successfully.") - } -} - -func findServiceFile(pattern, name string) string { - home, _ := os.UserHomeDir() - dir := filepath.Join(home, ".config", "containers", "systemd") - files, _ := filepath.Glob(filepath.Join(dir, pattern)) - re := regexp.MustCompile(`^[0-9]+_`) - for _, file := range files { - if strings.HasPrefix(filepath.Base(file), "99_") { - continue - } - serviceName := strings.TrimSuffix(filepath.Base(file), filepath.Ext(file)) - if pattern == "*.network" { - serviceName += "-network" - } - displayName := re.ReplaceAllString(serviceName, "") - if displayName == name { - return file - } - } - return "" -} - home, _ := os.UserHomeDir() - dir := filepath.Join(home, ".config", "containers", "systemd") - files, _ := filepath.Glob(filepath.Join(dir, pattern)) - re := regexp.MustCompile(`^[0-9]+_`) - for _, file := range files { - if strings.HasPrefix(filepath.Base(file), "99_") { - continue - } - serviceName := strings.TrimSuffix(filepath.Base(file), filepath.Ext(file)) - if pattern == "*.network" { - serviceName += "-network" - } - displayName := re.ReplaceAllString(serviceName, "") - if displayName == name { - return file - } - } - return "" -} - -func restartNetworks(sleepTime int) { - home, _ := os.UserHomeDir() - dir := filepath.Join(home, ".config", "containers", "systemd") - files, _ := filepath.Glob(filepath.Join(dir, "*.network")) - re := regexp.MustCompile(`^[0-9]+_`) - for _, file := range files { - if strings.HasPrefix(filepath.Base(file), "99_") { - continue - } - serviceName := strings.TrimSuffix(filepath.Base(file), ".network") + "-network" - displayName := re.ReplaceAllString(serviceName, "") - fmt.Printf("Restarting %s...\n", displayName) - if runCommand("systemctl", "--user", "try-restart", serviceName) || runCommand("systemctl", "--user", "start", serviceName) { - fmt.Printf(" ✓ %s restarted successfully\n", displayName) - } else { - fmt.Printf(" ✗ Failed to restart %s\n", displayName) - } - time.Sleep(time.Duration(sleepTime) * time.Second) - } -} - -func restartContainers(sleepTime int) { - home, _ := os.UserHomeDir() - dir := filepath.Join(home, ".config", "containers", "systemd") - files, _ := filepath.Glob(filepath.Join(dir, "*.container")) - re := regexp.MustCompile(`^[0-9]+_`) - for _, file := range files { - if strings.HasPrefix(filepath.Base(file), "99_") { - continue - } - serviceName := strings.TrimSuffix(filepath.Base(file), ".container") - displayName := re.ReplaceAllString(serviceName, "") - fmt.Printf("Restarting %s...\n", displayName) - if runCommand("systemctl", "--user", "restart", serviceName) { - fmt.Printf(" ✓ %s restarted successfully\n", displayName) - } else { - fmt.Printf(" ✗ Failed to restart %s\n", displayName) - } - time.Sleep(time.Duration(sleepTime) * time.Second) - } -} - -func restartNginx() { - home, _ := os.UserHomeDir() - dir := filepath.Join(home, ".config", "containers", "systemd") - files, _ := filepath.Glob(filepath.Join(dir, "*nginx*.container")) - if len(files) > 0 { - serviceName := strings.TrimSuffix(filepath.Base(files[0]), ".container") - fmt.Println("Restarting nginx...") - if runCommand("systemctl", "--user", "restart", serviceName) { - fmt.Println(" ✓ nginx restarted successfully") - } else { - fmt.Println(" ✗ Failed to restart nginx") - } - } -} - -func runCommand(name string, args ...string) bool { - cmd := exec.Command(name, args...) - err := cmd.Run() - return err == nil -} - -func printHelp() { - fmt.Println(`D U C K A I - C O M M A N D L I N E --------------------------------------------------------------------------------- - -Usage: duckai [options] - -Commands: - restart [--sleep N] [name] Restart all quadlet containers and networks, or a specific one by name (without prefix), reload systemd user daemon - help Show this help message - -Options: - --sleep N Sleep N seconds between restarts (default: 3)`) -} \ No newline at end of file diff --git a/BadAI/banner.sh b/BadAI/banner.sh deleted file mode 100644 index 5fc30b9..0000000 --- a/BadAI/banner.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash -# Lightweight banner for BadAI host system — Ubuntu with AMDGPU drivers - -oem_info() { - local v="" m="" d lv lm - for d in /sys/class/dmi/id /sys/devices/virtual/dmi/id; do - [[ -r "$d/sys_vendor" ]] && v=$(<"$d/sys_vendor") - [[ -r "$d/product_name" ]] && m=$(<"$d/product_name") - [[ -n "$v" || -n "$m" ]] && break - done - # ARM/SBC fallback - if [[ -z "$v" && -z "$m" && -r /proc/device-tree/model ]]; then - tr -d '\0' /dev/null 2>&1; then - name=$(lspci -nn 2>/dev/null | grep -Ei 'vga|display|gpu' | grep -i amd | head -n1 | cut -d: -f3-) - fi - name=$(printf '%s' "$name" | sed -e 's/^[[:space:]]\+//' -e 's/[[:space:]]\+$//' -e 's/[[:space:]]\{2,\}/ /g') - printf '%s\n' "${name:-Unknown AMD GPU}" -} - -ubuntu_version() { - lsb_release -d 2>/dev/null | cut -f2 || uname -a -} - -system_load() { - uptime | awk -F'load average:' '{ print $2 }' | sed 's/,//g' -} - -memory_usage() { - free -h | awk 'NR==2{printf "%.0f%%", $3*100/$2 }' -} - -updates_info() { - if command -v apt >/dev/null 2>&1; then - local upgradable=$(apt list --upgradable 2>/dev/null | grep -v '^Listing' | grep -c '^[^/]*$') - local security=$(apt list --upgradable 2>/dev/null | grep -c 'security') - printf '%d updates can be applied immediately.\n' "$upgradable" - if [[ $security -gt 0 ]]; then - printf '%d additional security updates can be applied.\n' "$security" - fi - else - printf 'Updates info not available.\n' - fi -} - -MACHINE="$(oem_info)" -GPU="$(gpu_name)" -UBUNTU_VER="$(ubuntu_version)" -LOAD="$(system_load)" -MEM="$(memory_usage)" - -echo -cat <<'ASCII' - -__________ .___ _____ .___ -\______ \_____ __| _/ / _ \ | | - | | _/\__ \ / __ | / /_\ \| | - | | \ / __ \_/ /_/ | / | \ | - |______ /(____ /\____ | \____|__ /___| - \/ \/ \/ \/ - - -B A D A I - H O S T ( U B U N T U , A M D G P U ) - -ASCII - -echo "--------------------------------------------------------------------------------" -printf 'Machine: %s\n' "$MACHINE" -printf 'GPU : %s\n' "$GPU" -printf 'OS : %s\n' "$UBUNTU_VER" -printf 'Load : %s\n' "$LOAD" -printf 'Memory : %s\n' "$MEM" - -echo -echo "--------------------------------------------------------------------------------" -updates_info - -echo -echo "--------------------------------------------------------------------------------" -printf 'Usage:\n' -printf ' - %-24s → %s\n' "podman ps" "List running containers" -printf ' - %-24s → %s\n' "podman logs " "View container logs" -printf ' - %-24s → %s\n' "podman exec -it bash" "Access container shell" -printf ' - %-24s → %s\n' "radentop" "Monitor AMD GPU usage (if installed)" -printf ' - %-24s → %s\n' "htop" "Monitor system processes and resources" -printf ' - %-24s → %s\n' "badai restart" "Restart all services" -printf ' - %-24s → %s\n' "badai help" "Show BadAI commands" \ No newline at end of file diff --git a/BadAI/issue b/BadAI/issue deleted file mode 100644 index 19c72f1..0000000 --- a/BadAI/issue +++ /dev/null @@ -1,8 +0,0 @@ -__________ .___ _____ .___ -\______ \_____ __| _/ / _ \ | | - | | _/\__ \ / __ | / /_\ \| | - | | \ / __ \_/ /_/ | / | \ | - |______ /(____ /\____ | \____|__ /___| - \/ \/ \/ \/ - -B A D A I - H O S T ( U B U N T U , A M D G P U ) diff --git a/README.md b/README.md index 01b6e29..1fa9cb1 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,157 @@ ``` -__________ .___ _____ .___ +__________ .___ _____ .___ \______ \_____ __| _/ / _ \ | | | | _/\__ \ / __ | / /_\ \| | | | \ / __ \_/ /_/ | / | \ | |______ /(____ /\____ | \____|__ /___| - \/ \/ \/ \/ - + \/ \/ \/ \/ + +B A D A I - H O S T ( D E B I A N , A M D G P U ) ``` -Guida completa per configurare un'infrastruttura AI containerizzata con Podman rootless su Ubuntu. -## 1. Prerequisiti +### Installazione -### Sistema Operativo -- Ubuntu 22.04 LTS o superiore -- Utente non-root con privilegi sudo +Infrastruttura AI containerizzata con Podman rootless su Ubuntu con GPU AMD. -### Partizionamento -| Mount Point | Size | Filesystem | Note | -|-------------|---------------|------------|------| -| /boot | 1 GB | ext4 | | -| / | 40 GB | ext4 | | -| /home | 50 GB | ext4 | se usi Podman rootless | -| /srv | tutto il resto| xfs | per dati, modelli AI, volumi bind | -| /swap | 16 GB | swap | | -## Installazione +##### Prerequisiti -Per installare automaticamente tutto il necessario, esegui: +- Debian 13 o superiore +- Utente non-root con privilegi sudo +- GPU AMD (opzionale, per ottimizzazioni) + + +##### 1. Aggiornare il sistema ```bash -curl -fsSL https://code.badstorm.xyz/SRV/bdi_podman_serverconf/raw/main/install.sh | sh +sudo apt update && sudo apt upgrade -y ``` -Questo script eseguirà tutti i passi di configurazione, inclusi aggiornamenti di sistema, installazione di Podman, configurazione di systemd e riavvio finale. +##### 2. Aggiungere l'utente ai gruppi render e video -## Utilizzo dopo l'installazione - -Dopo l'installazione e il riavvio, usa il comando `badai` per gestire i servizi AI containerizzati. - -### Comandi principali: -- `badai restart`: Riavvia tutti i container e le reti quadlet, ricarica il daemon systemd dell'utente. -- `badai restart [nome]`: Riavvia un servizio specifico per nome (senza prefisso numerico). -- `badai help`: Mostra il messaggio di aiuto. - -Esempi: ```bash -badai restart # Riavvia tutto -badai restart llamacpp # Riavvia solo il container llamacpp +sudo usermod -a -G render,video $LOGNAME +sudo loginctl enable-linger $USER +sudo sh -c "echo 'net.ipv4.ip_unprivileged_port_start=80' >> /etc/sysctl.conf" ``` -I servizi includono container come `llamacpp` per modelli AI e `nginx` per il proxy, oltre alle reti interne. +##### 3. Installare Podman e strumenti utili + +```bash +sudo apt install -y podman htop radeontop curl +``` + +##### 4. Creare cartelle per systemd containers + +```bash +mkdir -p ~/.config/containers/systemd +``` + +##### 5. Creare internal.network + +Crea il file `internal.network` nella directory systemd: + +```bash +tee ~/.config/containers/systemd/internal.network <<'EOF' +[Unit] +Description=Internal network for containers +After=network-online.target + +[Network] +NetworkName=internal +Subnet=10.10.0.0/24 +Gateway=10.10.0.1 +DNS=9.9.9.9 + +[Install] +WantedBy=default.target +EOF +``` + +##### 6. Aggiungere registri a /etc/containers/registries.conf + +```bash +printf "[registries.search]\nregistries = [\"docker.io\", \"quay.io\", \"ghcr.io\"]\n" | sudo tee -a /etc/containers/registries.conf > /dev/null +``` + +##### 7. Creare /srv/containers e assegnare permessi + +```bash +sudo mkdir -p /srv/containers +sudo chown -R $LOGNAME /srv/containers +``` + +##### 8. Banner SSH + +Per installare il banner SSH, crea il file `/etc/issue` e copia il banner al suo interno: + +```bash +sudo tee /etc/issue <<'EOF' +__________ .___ _____ .___ +\______ \_____ __| _/ / _ \ | | + | | _/\__ \ / __ | / /_\ \| | + | | \ / __ \_/ /_/ | / | \ | + |______ /(____ /\____ | \____|__ /___| + \/ \/ \/ \/ + +B A D A I - H O S T ( D E B I A N , A M D G P U ) +EOF +``` + +Se vuoi disabilitare altri script MOTD: + +```bash +sudo bash -c 'for f in /etc/update-motd.d/*; do if [ -f "$f" ]; then mv "$f" "${f}.disabled"; fi; done' +``` + +Visualizza il banner con: + +```bash +cat /etc/issue +``` + +##### 9. Configurare GRUB per GPU AMD + +Se hai una GPU AMD, configura GRUB con i parametri appropriati: + +```bash +# Seleziona la quantità di RAM disponibile: 16, 24, 32 o 48 GB +# Esempio per 32GB: +sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="amdgpu.gttsize=32768 amdttm.pages_limit=36864000"/' /etc/default/grub +sudo update-grub +sudo reboot +``` + +**Valori di riferimento per GPU AMD:** +- 16 GB RAM: `amdgpu.gttsize=16384 amdttm.pages_limit=18432000` +- 24 GB RAM: `amdgpu.gttsize=24576 amdttm.pages_limit=27648000` +- 32 GB RAM: `amdgpu.gttsize=32768 amdttm.pages_limit=36864000` +- 48 GB RAM: `amdgpu.gttsize=49152 amdttm.pages_limit=55296000` + +##### 10. Scaricare file container specifici + +```bash +REPO_URL="https://code.badstorm.xyz/SRV/bdi_podman_serverconf/raw/main" +curl -fsSL $REPO_URL/containers/llamacpp/llamacpp.container -o ~/.config/containers/systemd/llamacpp.container +curl -fsSL $REPO_URL/containers/nginx/nginx.container -o ~/.config/containers/systemd/nginx.container +``` + +##### 11. Avviare i servizi + +```bash +systemctl --user daemon-reload +systemctl --user start internal.network +systemctl --user start llamacpp nginx +``` + +##### 12. Utilizzo + +Dopo l'installazione, i servizi container possono essere gestiti con: + +```bash +podman ps # Elencare container attivi +podman logs # Visualizzare log +systemctl --user status # Verificare lo stato +systemctl --user restart # Riavviare un servizio +``` \ No newline at end of file diff --git a/Services/giteamcp/giteamcp.Containerfile b/Services/giteamcp/giteamcp.Containerfile deleted file mode 100644 index ab745cd..0000000 --- a/Services/giteamcp/giteamcp.Containerfile +++ /dev/null @@ -1,36 +0,0 @@ -# Gitea MCP Server Container -# -### BUILD: podman build -t gitea-mcp:latest -f Containerfile . -### Export: podman save -o /home/badstorm/gitea-mcp.tar localhost/gitea-mcp:latest - -FROM debian:13-slim - -# Install runtime dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - curl \ - tar \ - && rm -rf /var/lib/apt/lists/* - -# Create app user -RUN useradd -m -u 1000 gitea-mcp - -# Download and extract binary release -RUN curl -L https://gitea.com/gitea/gitea-mcp/releases/download/v1.0.1/gitea-mcp_Linux_x86_64.tar.gz -o /tmp/gitea-mcp.tar.gz && \ - tar -xzf /tmp/gitea-mcp.tar.gz -C /usr/local/bin/ && \ - chmod +x /usr/local/bin/gitea-mcp && \ - rm /tmp/gitea-mcp.tar.gz - -# Create log directory -RUN mkdir -p /home/gitea-mcp/.gitea-mcp && \ - chown -R gitea-mcp:gitea-mcp /home/gitea-mcp - -# Switch to non-root user -USER gitea-mcp - -# Set environment variables -ENV GITEA_HOST=${GITEA_HOST:-https://gitea.com} - -# Run the application -ENTRYPOINT ["/usr/local/bin/gitea-mcp"] -CMD ["-t", "stdio"] diff --git a/Services/giteamcp/giteamcp.container b/Services/giteamcp/giteamcp.container deleted file mode 100644 index 038061e..0000000 --- a/Services/giteamcp/giteamcp.container +++ /dev/null @@ -1,25 +0,0 @@ -[Container] -ContainerName=gitea-mcp -Image=localhost/gitea-mcp:latest -#AutoUpdate=registry -Network=host - -#Environment=GITEA_ACCESS_TOKEN=your_token_here -Environment=GITEA_HOST=https://gitea.com -Environment=GITEA_INSECURE=false - -PublishPort=8080:8080 -Exec=-t http --port 8080 - -# Arguments for stdio mode -# Exec=-t stdio - -# Optional: Volume for persistent logs -#Volume=/srv/containers/gitea-mcp/.gitea-mcp:/home/gitea-mcp/.gitea-mcp - -[Service] -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target default.target \ No newline at end of file diff --git a/Services/lemonade/lemonade-ubuntu.Containerfile b/Services/lemonade/lemonade-ubuntu.Containerfile deleted file mode 100644 index c777e32..0000000 --- a/Services/lemonade/lemonade-ubuntu.Containerfile +++ /dev/null @@ -1,43 +0,0 @@ -# Lemonade Server ROCm Containerfile with lightweight runtime base -# Build: podman build -t lemonade:ubuntu-amd64 -f lemonade-ubuntu.Containerfile . -# Export: podman save -o /home/duckpage/lemonade-ubuntu-amd64.tar localhost/lemonade:ubuntu-amd64 - -# ========================= -# Stage: Runtime (Lightweight ROCm runtime) -# ========================= -FROM ubuntu:24.04 - -USER root -EXPOSE 8000 - -# Install Lemonade SDK -COPY *.deb /tmp/ -RUN apt-get update && apt-get install -y nano unzip wget curl jq pciutils ffmpeg libatomic1 && \ - apt-get clean && rm -rf /var/lib/apt/lists/* && \ - update-pciids && \ - VERSION=$(curl -s https://api.github.com/repos/lemonade-sdk/lemonade/releases/latest | jq -r .tag_name | sed 's/^v//') && \ - DEB_FILE=$(ls /tmp/*.deb 2>/dev/null | head -1) && \ - if [ -n "$DEB_FILE" ]; then \ - cp "$DEB_FILE" /tmp/lemonade-server-minimal.deb; \ - else \ - wget -O /tmp/lemonade-server-minimal.deb \ - https://github.com/lemonade-sdk/lemonade/releases/download/v${VERSION}/lemonade-server-minimal_${VERSION}_amd64.deb; \ - fi && \ - dpkg -i /tmp/lemonade-server-minimal.deb || apt-get install -fy && \ - rm /tmp/lemonade-server-minimal.deb - -# Fix Proxy -COPY lemonade.fix-proxy.sh /usr/local/bin/fix-proxy.sh -RUN chmod +x /usr/local/bin/fix-proxy.sh -RUN /usr/local/bin/fix-proxy.sh - -ENV LEMONADE_LLAMACPP=vulkan -ENV LEMONADE_HOST=0.0.0.0 -ENV LEMONADE_PORT=8000 -ENV LEMONADE_CTX_SIZE=131072 - -# Se nel tuo base usi un utente non-root (es. appuser), scommenta: -# USER appuser - -ENTRYPOINT ["lemonade-server"] -CMD ["serve"] diff --git a/Services/lemonade/lemonade.container b/Services/lemonade/lemonade.container deleted file mode 100644 index 131dd50..0000000 --- a/Services/lemonade/lemonade.container +++ /dev/null @@ -1,33 +0,0 @@ -[Container] -ContainerName=lemonade -Image=localhost/lemonade:ubuntu-amd64 -#AutoUpdate=registry -Network=internal.network -PublishPort=8000:8000 - -# Production - Lemonade usa Hugging Face Hub per i modelli -Volume=/srv/containers/aitools/models/lemonade:/root/.cache/huggingface -Volume=/srv/containers/aitools/config/lemonade:/root/.cache/lemonade - -# ROCm tuning -AddDevice=/dev/dri/renderD128 -PodmanArgs=--group-add=keep-groups --ipc=host -SecurityLabelType=container_runtime_t - -Environment=LEMONADE_LLAMACPP=vulkan -Environment=LEMONADE_HOST=0.0.0.0 -Environment=LEMONADE_PORT=8000 -Environment=LEMONADE_LLAMACPP_ARGS="--no-mmap --no-warmup" -Environment=LEMONADE_CTX_SIZE=131072 - -# HF -Environment=HF_HOME=/root/.cache/huggingface -Environment=HF_TOKEN=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 - - -[Service] -Restart=on-failure -TimeoutStartSec=15m - -[Install] -WantedBy=multi-user.target default.target diff --git a/Services/lemonade/lemonade.fix-proxy.sh b/Services/lemonade/lemonade.fix-proxy.sh deleted file mode 100644 index 057368f..0000000 --- a/Services/lemonade/lemonade.fix-proxy.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# fix-shared-js.sh — sostituisce la funzione getServerBaseUrl con window.location.origin - -set -e - -TARGET="/usr/local/share/lemonade-server/resources/static/js/shared.js" -TMP="$(mktemp)" - -if [ ! -f "$TARGET" ]; then - echo "File non trovato: $TARGET" - exit 1 -fi - -# Copia il file in un temporaneo -cp "$TARGET" "$TMP" - -# Rimuove il blocco della funzione esistente (apertura fino alla chiusura }) -# e inserisce la nuova definizione. Usa awk per gestire blocchi multi-linea. -awk ' - BEGIN { skip=0 } - /function[[:space:]]+getServerBaseUrl[[:space:]]*\(/ { - skip=1 - next - } - skip==1 { - # cerca la chiusura della funzione (prima graffa singola a fine riga) - if ($0 ~ /^}/) { - skip=0 - # inserisce la nuova funzione al posto di quella rimossa - print "function getServerBaseUrl() { return window.location.origin; }" - } - next - } - { print } -' "$TMP" > "$TARGET" - -# Verifica che la nuova funzione sia presente -if grep -q 'function getServerBaseUrl() { return window.location.origin; }' "$TARGET"; then - echo "Patch applicata con successo." -else - echo "Patch non riuscita: la nuova funzione non è stata trovata." - exit 1 -fi diff --git a/Services/lemonade/lemonade.nginx b/Services/lemonade/lemonade.nginx deleted file mode 100644 index 0d6d3cb..0000000 --- a/Services/lemonade/lemonade.nginx +++ /dev/null @@ -1,114 +0,0 @@ -map $http_upgrade $connection_upgrade { - default upgrade; - '' close; -} - -server { - listen 80; - server_name models.badstorm.xyz; - return 301 https://$server_name$request_uri; -} - -server { - listen 443 ssl; - listen [::]:443 ssl; - server_name models.badstorm.xyz; - charset utf-8; - keepalive_timeout 0; - - # SSL - ssl_certificate /etc/nginx/ssl/live/ai.duckpage.net/fullchain.pem; - ssl_certificate_key /etc/nginx/ssl/live/ai.duckpage.net/privkey.pem; - - # Improve HTTPS performance with session resumption - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - - # SSL Protocols and Ciphers - ssl_protocols TLSv1.3; - ssl_prefer_server_ciphers off; - ssl_dhparam /etc/nginx/ssl/dhparam.pem; - ssl_ecdh_curve secp521r1:secp384r1; - - # Security Headers - add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; - add_header X-Frame-Options SAMEORIGIN always; - add_header X-Content-Type-Options nosniff always; - add_header X-Xss-Protection "1; mode=block" always; - - # OCSP Stapling - ssl_stapling on; - ssl_stapling_verify on; - ssl_trusted_certificate /etc/nginx/ssl/live/ai.duckpage.net/fullchain.pem; - resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] valid=300s; - resolver_timeout 5s; - - client_max_body_size 512M; - client_body_buffer_size 128k; - - # Gzip - gzip on; - gzip_types text/plain text/xml text/css application/xhtml+xml application/xml image/svg+xml application/rss+xml application/atom_xml application/javascript application/x-javascript application/x-httpd-php application/x-httpd-fastphp application/x-httpd-eruby; - - # ============================== - # Proxy per LLM /api/v1 (Copilot) - # ============================== - location /api/v1 { - proxy_http_version 1.1; - - # WebSocket + SSE Support - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - - # ESSENZIALI per LLM (streaming) - proxy_buffering off; - proxy_request_buffering off; - proxy_cache off; - - # Timeouts alti perché Copilot mantiene le connessioni aperte - proxy_connect_timeout 3600; - proxy_send_timeout 3600; - proxy_read_timeout 3600; - send_timeout 3600; - - # Header classici - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_pass http://lemonade:8000/api/v1; - } - - # ============================== - # Proxy main UI / altri endpoint - # ============================== - location / { - proxy_http_version 1.1; - - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - - # Se anche qui hai streaming, puoi tenere questi: - proxy_buffering off; - proxy_request_buffering off; - proxy_cache off; - - proxy_connect_timeout 600; - proxy_send_timeout 600; - proxy_read_timeout 600; - send_timeout 600; - - proxy_redirect off; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_pass http://lemonade:8000; - } - - location ~ /\.ht { - deny all; - } -} \ No newline at end of file diff --git a/Services/llamacpp-multi/README.md b/Services/llamacpp-multi/README.md deleted file mode 100644 index d7e50e4..0000000 --- a/Services/llamacpp-multi/README.md +++ /dev/null @@ -1,129 +0,0 @@ -# LLaMACpp Multi-Instance Setup - -Guida per configurare e scalare il numero di istanze di llama-server con load balancing nginx. - -## Struttura Attuale - -- **4 istanze** di llama-server (porte 9000-9003) -- **Nginx** come load balancer (porta 8090) -- **Supervisor** per gestire tutti i processi - -## Aggiungere Istanze - -Se vuoi aumentare il numero di istanze, segui questi step: - -### 1. Modifica il Containerfile - -File: `llamacpp-multi.Containerfile` - -Cambia: -```dockerfile -ENV LLAMA_INSTANCES=4 -``` - -Con il numero di istanze desiderato (es. 6): -```dockerfile -ENV LLAMA_INSTANCES=6 -``` - -### 2. Aggiorna la Configurazione Nginx - -File: `llama-upstream.conf` - -Aggiungi i server nei porti nuovi nel blocco `upstream llama_backend`: - -```nginx -upstream llama_backend { - least_conn; - server 127.0.0.1:9000 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9001 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9002 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9003 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9004 max_fails=3 fail_timeout=30s; # NUOVO - server 127.0.0.1:9005 max_fails=3 fail_timeout=30s; # NUOVO -} -``` - -### 3. Aggiorna il Containerfile con le porte esposte - -File: `llamacpp-multi.Containerfile` - -Aggiungi le nuove porte: -```dockerfile -EXPOSE 8090 9000 9001 9002 9003 9004 9005 -``` - -### 4. Ricompila il Container - -```bash -cd /home/badstorm/Source/bdi/bdi_podman_serverconf/Services/llamacpp-multi -podman build -t llamacpp:vulkan-multi-amd64 -f llamacpp-multi.Containerfile . -``` - -### 5. Riavvia il Servizio - -```bash -systemctl restart llamacpp-multi -``` - -## Considerazioni di Risorse - -Ogni istanza consuma: -- **~8GB VRAM** (dipende dal modello e da `LLAMA_ARG_CTX_SIZE`) -- **~1-2 CPU core** (dipende dal carico) - -**Con GPU AMD Radeon (RENOIR):** -- 2 istanze: ✅ Stabile -- 4 istanze: ⚠️ Funziona ma monitorare memoria -- 6+ istanze: ❌ Probabilmente fuori di VRAM - -Monitora con: -```bash -podman stats llamacpp-multi -``` - -## Variabili di Ambiente Modificabili - -Nel file `.container` puoi sovrascrivere: - -```ini -Environment=LLAMA_ARG_PARALLEL=32 -Environment=LLAMA_ARG_THREADS=16 -Environment=LLAMA_ARG_BATCH_SIZE=2048 -Environment=LLAMA_ARG_CTX_SIZE=131072 -Environment=LLAMA_ARG_HF_REPO=unsloth/Qwen3-Coder-Next-GGUF:Q2_K_XL -Environment=LLAMA_READY_TIMEOUT=600 -``` - -## Testing - -Una volta avviate le istanze, testa: - -```bash -curl http://localhost:8090/v1/models -``` - -Dovresti vedere il modello listato se tutte le istanze sono pronte. - -Test di carico (concurrent requests): -```bash -for i in {1..10}; do - curl -X POST http://localhost:8090/api/completion \ - -H "Content-Type: application/json" \ - -d '{"prompt": "Once upon a time", "n_predict": 64}' & -done -wait -``` - -## Troubleshooting - -**502 Bad Gateway:** -```bash -podman exec llamacpp-multi tail -f /var/log/llama-server-9000.log -``` - -**Timeout Ready:** -Aumenta `LLAMA_READY_TIMEOUT` se il modello impiega più di 10 minuti a caricare. - -**Out of Memory:** -Riduci `LLAMA_ARG_PARALLEL`, `LLAMA_ARG_BATCH_SIZE`, o `LLAMA_ARG_CTX_SIZE`. diff --git a/Services/llamacpp-multi/llama-multi.conf b/Services/llamacpp-multi/llama-multi.conf deleted file mode 100644 index 241ce74..0000000 --- a/Services/llamacpp-multi/llama-multi.conf +++ /dev/null @@ -1,17 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/var/log/supervisor/supervisord.log - -[program:nginx] -command=/usr/sbin/nginx -g "daemon off;" -autostart=true -autorestart=true -stderr_logfile=/var/log/nginx/error.log -stdout_logfile=/var/log/nginx/access.log - -[program:llama-servers] -command=/app/bin/start-multi-servers.sh -autostart=true -autorestart=false -stderr_logfile=/var/log/llama-servers.log -stdout_logfile=/var/log/llama-servers.log diff --git a/Services/llamacpp-multi/llama-upstream.conf b/Services/llamacpp-multi/llama-upstream.conf deleted file mode 100644 index 8a279bd..0000000 --- a/Services/llamacpp-multi/llama-upstream.conf +++ /dev/null @@ -1,35 +0,0 @@ -upstream llama_backend { - least_conn; - server 127.0.0.1:9000 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9001 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9002 max_fails=3 fail_timeout=30s; - server 127.0.0.1:9003 max_fails=3 fail_timeout=30s; -} - -server { - listen 8090; - server_name _; - - client_max_body_size 512M; - - location / { - proxy_pass http://llama_backend; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_buffering off; - proxy_request_buffering off; - proxy_read_timeout 600s; - proxy_connect_timeout 30s; - } - - location /health { - access_log off; - return 200 "healthy\n"; - add_header Content-Type text/plain; - } -} diff --git a/Services/llamacpp-multi/llamacpp-multi.Containerfile b/Services/llamacpp-multi/llamacpp-multi.Containerfile deleted file mode 100644 index 9f37af8..0000000 --- a/Services/llamacpp-multi/llamacpp-multi.Containerfile +++ /dev/null @@ -1,62 +0,0 @@ -### LLaMACpp Multi-Instance Container with Nginx Load Balancer -### Based on llama-throughput-lab for maximum throughput -### Multiple llama-server instances + nginx for load balancing -### -### BUILD: podman build -t llamacpp:vulkan-multi-amd64 -f llamacpp-multi.Containerfile . -### Export: podman save -o /home/badstorm/llamacpp-vulkan-multi-amd64.tar localhost/llamacpp:vulkan-multi-amd64 - - -FROM ubuntu:24.04 - -USER root -EXPOSE 8090 9000 9001 9002 9003 - -RUN apt-get update \ - && apt-get install -y curl tar grep sed git ffmpeg nano python3-pip python3 python3-wheel nginx supervisor \ - && pip install --break-system-packages --upgrade setuptools \ - && pip install --break-system-packages -U "huggingface_hub[cli]" \ - && if [ -f requirements.txt ]; then pip install --break-system-packages -r requirements.txt; fi \ - && apt autoremove -y \ - && apt clean -y \ - && rm -rf /tmp/* /var/tmp/* \ - && rm -rf /var/lib/apt/lists/* \ - && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ - && find /var/cache -type f -delete - -WORKDIR /app - -RUN VERSION=$(curl -s https://api.github.com/repos/ggml-org/llama.cpp/releases/latest | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": "\([^"]*\)".*/\1/') \ - && echo "Last llama.cpp version: $VERSION" \ - && curl -L https://github.com/ggml-org/llama.cpp/releases/download/${VERSION}/llama-${VERSION}-bin-ubuntu-vulkan-x64.tar.gz -o llama.tar.gz \ - && tar -xzf llama.tar.gz -C . --strip-components=1 \ - && rm llama.tar.gz - -RUN chmod +x /app/llama-server - -# Copy startup script for multiple instances -COPY start-multi-servers.sh /app/bin/ -RUN chmod +x /app/bin/start-multi-servers.sh - -# Copy nginx config -COPY llama-upstream.conf /etc/nginx/conf.d/ - -# Copy supervisor config -COPY llama-multi.conf /etc/supervisor/conf.d/ - -WORKDIR /app - -ENV PATH=/app:/app/bin:$PATH -ENV LD_LIBRARY_PATH=/app:$LD_LIBRARY_PATH -ENV HF_HUB_ENABLE_HF_TRANSFER=1 -ENV LLAMA_INSTANCES=4 -ENV LLAMA_BASE_PORT=9000 -ENV LLAMA_ARG_PARALLEL=32 -ENV LLAMA_ARG_THREADS=16 -ENV LLAMA_ARG_BATCH_SIZE=2048 -ENV LLAMA_ARG_CTX_SIZE=131072 -ENV LLAMA_ARG_HF_REPO=unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q2_K -ENV LLAMA_ARG_HOST=0.0.0.0 -ENV LLAMA_READY_TIMEOUT=600 - -ENTRYPOINT ["/usr/bin/supervisord"] -CMD ["-c", "/etc/supervisor/conf.d/llama-multi.conf"] diff --git a/Services/llamacpp-multi/llamacpp-multi.container b/Services/llamacpp-multi/llamacpp-multi.container deleted file mode 100644 index 82b4c32..0000000 --- a/Services/llamacpp-multi/llamacpp-multi.container +++ /dev/null @@ -1,36 +0,0 @@ -[Container] -ContainerName=llamacpp-multi -Image=localhost/llamacpp:vulkan-multi-amd64 -#AutoUpdate=registry -Network=internal.network -PublishPort=8090:8090 - -# Production - Lemonade usa Hugging Face Hub per i modelli -Volume=/srv/containers/aitools/models:/root/.cache/llama.cpp - -# ROCm tuning -AddDevice=/dev/dri/renderD128 -PodmanArgs=--group-add=keep-groups --ipc=host -SecurityLabelType=container_runtime_t - -# Multi-instance configuration (throughput optimized) -Environment=LLAMA_INSTANCES=4 -Environment=LLAMA_BASE_PORT=9000 -Environment=LLAMA_ARG_HOST=0.0.0.0 -Environment=LLAMA_ARG_PARALLEL=32 -Environment=LLAMA_ARG_THREADS=16 -Environment=LLAMA_ARG_BATCH_SIZE=2048 -Environment=LLAMA_ARG_CTX_SIZE=131072 -Environment=LLAMA_ARG_HF_REPO=unsloth/Qwen3-Coder-Next-GGUF:Q2_K_XL - -# HF -Environment=HF_HOME=/root/.cache/huggingface -Environment=HF_TOKEN=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 - - -[Service] -Restart=on-failure -TimeoutStartSec=15m - -[Install] -WantedBy=multi-user.target default.target diff --git a/Services/llamacpp-multi/start-multi-servers.sh b/Services/llamacpp-multi/start-multi-servers.sh deleted file mode 100644 index 0161d1c..0000000 --- a/Services/llamacpp-multi/start-multi-servers.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -set -e - -INSTANCES=${LLAMA_INSTANCES:-2} -BASE_PORT=${LLAMA_BASE_PORT:-9000} -READY_TIMEOUT=${LLAMA_READY_TIMEOUT:-600} - -echo "Starting $INSTANCES llama-server instances on ports $BASE_PORT-$((BASE_PORT+INSTANCES-1))" - -for ((i=0; i /var/log/llama-server-$PORT.log 2>&1 & - sleep 3 -done - -echo "Waiting for servers to be ready..." -for ((i=0; i /dev/null 2>&1; then - echo "Instance on port $PORT is ready" - break - fi - sleep 5 - elapsed=$((elapsed + 5)) - done - if [ $elapsed -ge $READY_TIMEOUT ]; then - echo "ERROR: Server on port $PORT did not become ready after ${READY_TIMEOUT}s" - fi -done - -echo "All instances ready. Monitoring logs..." -tail -f /var/log/llama-server-*.log & -wait diff --git a/Services/llamacpp-swap/DOCS.md b/Services/llamacpp-swap/DOCS.md deleted file mode 100644 index b5ef56c..0000000 --- a/Services/llamacpp-swap/DOCS.md +++ /dev/null @@ -1,445 +0,0 @@ ------ common params ----- - --h, --help, --usage print usage and exit ---version show version and build info ---completion-bash print source-able bash completion script for llama.cpp ---verbose-prompt print a verbose prompt before generation (default: false) --t, --threads N number of CPU threads to use during generation (default: -1) - (env: LLAMA_ARG_THREADS) --tb, --threads-batch N number of threads to use during batch and prompt processing (default: - same as --threads) --C, --cpu-mask M CPU affinity mask: arbitrarily long hex. Complements cpu-range - (default: "") --Cr, --cpu-range lo-hi range of CPUs for affinity. Complements --cpu-mask ---cpu-strict <0|1> use strict CPU placement (default: 0) ---prio N set process/thread priority : low(-1), normal(0), medium(1), high(2), - realtime(3) (default: 0) ---poll <0...100> use polling level to wait for work (0 - no polling, default: 50) --Cb, --cpu-mask-batch M CPU affinity mask: arbitrarily long hex. Complements cpu-range-batch - (default: same as --cpu-mask) --Crb, --cpu-range-batch lo-hi ranges of CPUs for affinity. Complements --cpu-mask-batch ---cpu-strict-batch <0|1> use strict CPU placement (default: same as --cpu-strict) ---prio-batch N set process/thread priority : 0-normal, 1-medium, 2-high, 3-realtime - (default: 0) ---poll-batch <0|1> use polling to wait for work (default: same as --poll) --c, --ctx-size N size of the prompt context (default: 4096, 0 = loaded from model) - (env: LLAMA_ARG_CTX_SIZE) --n, --predict, --n-predict N number of tokens to predict (default: -1, -1 = infinity) - (env: LLAMA_ARG_N_PREDICT) --b, --batch-size N logical maximum batch size (default: 2048) - (env: LLAMA_ARG_BATCH) --ub, --ubatch-size N physical maximum batch size (default: 512) - (env: LLAMA_ARG_UBATCH) ---keep N number of tokens to keep from the initial prompt (default: 0, -1 = - all) ---swa-full use full-size SWA cache (default: false) - [(more - info)](https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) - (env: LLAMA_ARG_SWA_FULL) ---kv-unified, -kvu use single unified KV buffer for the KV cache of all sequences - (default: false) - [(more info)](https://github.com/ggml-org/llama.cpp/pull/14363) - (env: LLAMA_ARG_KV_SPLIT) --fa, --flash-attn [on|off|auto] set Flash Attention use ('on', 'off', or 'auto', default: 'auto') - (env: LLAMA_ARG_FLASH_ATTN) ---no-perf disable internal libllama performance timings (default: false) - (env: LLAMA_ARG_NO_PERF) --e, --escape process escapes sequences (\n, \r, \t, \', \", \\) (default: true) ---no-escape do not process escape sequences ---rope-scaling {none,linear,yarn} RoPE frequency scaling method, defaults to linear unless specified by - the model - (env: LLAMA_ARG_ROPE_SCALING_TYPE) ---rope-scale N RoPE context scaling factor, expands context by a factor of N - (env: LLAMA_ARG_ROPE_SCALE) ---rope-freq-base N RoPE base frequency, used by NTK-aware scaling (default: loaded from - model) - (env: LLAMA_ARG_ROPE_FREQ_BASE) ---rope-freq-scale N RoPE frequency scaling factor, expands context by a factor of 1/N - (env: LLAMA_ARG_ROPE_FREQ_SCALE) ---yarn-orig-ctx N YaRN: original context size of model (default: 0 = model training - context size) - (env: LLAMA_ARG_YARN_ORIG_CTX) ---yarn-ext-factor N YaRN: extrapolation mix factor (default: -1.0, 0.0 = full - interpolation) - (env: LLAMA_ARG_YARN_EXT_FACTOR) ---yarn-attn-factor N YaRN: scale sqrt(t) or attention magnitude (default: -1.0) - (env: LLAMA_ARG_YARN_ATTN_FACTOR) ---yarn-beta-slow N YaRN: high correction dim or alpha (default: -1.0) - (env: LLAMA_ARG_YARN_BETA_SLOW) ---yarn-beta-fast N YaRN: low correction dim or beta (default: -1.0) - (env: LLAMA_ARG_YARN_BETA_FAST) --nkvo, --no-kv-offload disable KV offload - (env: LLAMA_ARG_NO_KV_OFFLOAD) --nr, --no-repack disable weight repacking - (env: LLAMA_ARG_NO_REPACK) ---no-host bypass host buffer allowing extra buffers to be used - (env: LLAMA_ARG_NO_HOST) --ctk, --cache-type-k TYPE KV cache data type for K - allowed values: f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1 - (default: f16) - (env: LLAMA_ARG_CACHE_TYPE_K) --ctv, --cache-type-v TYPE KV cache data type for V - allowed values: f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1 - (default: f16) - (env: LLAMA_ARG_CACHE_TYPE_V) --dt, --defrag-thold N KV cache defragmentation threshold (DEPRECATED) - (env: LLAMA_ARG_DEFRAG_THOLD) --np, --parallel N number of parallel sequences to decode (default: 1) - (env: LLAMA_ARG_N_PARALLEL) ---mlock force system to keep model in RAM rather than swapping or compressing - (env: LLAMA_ARG_MLOCK) ---no-mmap do not memory-map model (slower load but may reduce pageouts if not - using mlock) - (env: LLAMA_ARG_NO_MMAP) ---numa TYPE attempt optimizations that help on some NUMA systems - - distribute: spread execution evenly over all nodes - - isolate: only spawn threads on CPUs on the node that execution - started on - - numactl: use the CPU map provided by numactl - if run without this previously, it is recommended to drop the system - page cache before using this - see https://github.com/ggml-org/llama.cpp/issues/1437 - (env: LLAMA_ARG_NUMA) --dev, --device comma-separated list of devices to use for offloading (none = don't - offload) - use --list-devices to see a list of available devices - (env: LLAMA_ARG_DEVICE) ---list-devices print list of available devices and exit ---override-tensor, -ot =,... - override tensor buffer type ---cpu-moe, -cmoe keep all Mixture of Experts (MoE) weights in the CPU - (env: LLAMA_ARG_CPU_MOE) ---n-cpu-moe, -ncmoe N keep the Mixture of Experts (MoE) weights of the first N layers in the - CPU - (env: LLAMA_ARG_N_CPU_MOE) --ngl, --gpu-layers, --n-gpu-layers N max. number of layers to store in VRAM (default: -1) - (env: LLAMA_ARG_N_GPU_LAYERS) --sm, --split-mode {none,layer,row} how to split the model across multiple GPUs, one of: - - none: use one GPU only - - layer (default): split layers and KV across GPUs - - row: split rows across GPUs - (env: LLAMA_ARG_SPLIT_MODE) --ts, --tensor-split N0,N1,N2,... fraction of the model to offload to each GPU, comma-separated list of - proportions, e.g. 3,1 - (env: LLAMA_ARG_TENSOR_SPLIT) --mg, --main-gpu INDEX the GPU to use for the model (with split-mode = none), or for - intermediate results and KV (with split-mode = row) (default: 0) - (env: LLAMA_ARG_MAIN_GPU) ---check-tensors check model tensor data for invalid values (default: false) ---override-kv KEY=TYPE:VALUE advanced option to override model metadata by key. may be specified - multiple times. - types: int, float, bool, str. example: --override-kv - tokenizer.ggml.add_bos_token=bool:false ---no-op-offload disable offloading host tensor operations to device (default: false) ---lora FNAME path to LoRA adapter (can be repeated to use multiple adapters) ---lora-scaled FNAME SCALE path to LoRA adapter with user defined scaling (can be repeated to use - multiple adapters) ---control-vector FNAME add a control vector - note: this argument can be repeated to add multiple control vectors ---control-vector-scaled FNAME SCALE add a control vector with user defined scaling SCALE - note: this argument can be repeated to add multiple scaled control - vectors ---control-vector-layer-range START END - layer range to apply the control vector(s) to, start and end inclusive --m, --model FNAME model path (default: `models/$filename` with filename from `--hf-file` - or `--model-url` if set, otherwise models/7B/ggml-model-f16.gguf) - (env: LLAMA_ARG_MODEL) --mu, --model-url MODEL_URL model download url (default: unused) - (env: LLAMA_ARG_MODEL_URL) --dr, --docker-repo [/][:quant] - Docker Hub model repository. repo is optional, default to ai/. quant - is optional, default to :latest. - example: gemma3 - (default: unused) - (env: LLAMA_ARG_DOCKER_REPO) --hf, -hfr, --hf-repo /[:quant] - Hugging Face model repository; quant is optional, case-insensitive, - default to Q4_K_M, or falls back to the first file in the repo if - Q4_K_M doesn't exist. - mmproj is also downloaded automatically if available. to disable, add - --no-mmproj - example: unsloth/phi-4-GGUF:q4_k_m - (default: unused) - (env: LLAMA_ARG_HF_REPO) --hfd, -hfrd, --hf-repo-draft /[:quant] - Same as --hf-repo, but for the draft model (default: unused) - (env: LLAMA_ARG_HFD_REPO) --hff, --hf-file FILE Hugging Face model file. If specified, it will override the quant in - --hf-repo (default: unused) - (env: LLAMA_ARG_HF_FILE) --hfv, -hfrv, --hf-repo-v /[:quant] - Hugging Face model repository for the vocoder model (default: unused) - (env: LLAMA_ARG_HF_REPO_V) --hffv, --hf-file-v FILE Hugging Face model file for the vocoder model (default: unused) - (env: LLAMA_ARG_HF_FILE_V) --hft, --hf-token TOKEN Hugging Face access token (default: value from HF_TOKEN environment - variable) - (env: HF_TOKEN) ---log-disable Log disable ---log-file FNAME Log to file ---log-colors [on|off|auto] Set colored logging ('on', 'off', or 'auto', default: 'auto') - 'auto' enables colors when output is to a terminal - (env: LLAMA_LOG_COLORS) --v, --verbose, --log-verbose Set verbosity level to infinity (i.e. log all messages, useful for - debugging) ---offline Offline mode: forces use of cache, prevents network access - (env: LLAMA_OFFLINE) --lv, --verbosity, --log-verbosity N Set the verbosity threshold. Messages with a higher verbosity will be - ignored. - (env: LLAMA_LOG_VERBOSITY) ---log-prefix Enable prefix in log messages - (env: LLAMA_LOG_PREFIX) ---log-timestamps Enable timestamps in log messages - (env: LLAMA_LOG_TIMESTAMPS) --ctkd, --cache-type-k-draft TYPE KV cache data type for K for the draft model - allowed values: f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1 - (default: f16) - (env: LLAMA_ARG_CACHE_TYPE_K_DRAFT) --ctvd, --cache-type-v-draft TYPE KV cache data type for V for the draft model - allowed values: f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1 - (default: f16) - (env: LLAMA_ARG_CACHE_TYPE_V_DRAFT) - - ------ sampling params ----- - ---samplers SAMPLERS samplers that will be used for generation in the order, separated by - ';' - (default: - penalties;dry;top_n_sigma;top_k;typ_p;top_p;min_p;xtc;temperature) --s, --seed SEED RNG seed (default: -1, use random seed for -1) ---sampling-seq, --sampler-seq SEQUENCE - simplified sequence for samplers that will be used (default: - edskypmxt) ---ignore-eos ignore end of stream token and continue generating (implies - --logit-bias EOS-inf) ---temp N temperature (default: 0.8) ---top-k N top-k sampling (default: 40, 0 = disabled) ---top-p N top-p sampling (default: 0.9, 1.0 = disabled) ---min-p N min-p sampling (default: 0.1, 0.0 = disabled) ---top-nsigma N top-n-sigma sampling (default: -1.0, -1.0 = disabled) ---xtc-probability N xtc probability (default: 0.0, 0.0 = disabled) ---xtc-threshold N xtc threshold (default: 0.1, 1.0 = disabled) ---typical N locally typical sampling, parameter p (default: 1.0, 1.0 = disabled) ---repeat-last-n N last n tokens to consider for penalize (default: 64, 0 = disabled, -1 - = ctx_size) ---repeat-penalty N penalize repeat sequence of tokens (default: 1.0, 1.0 = disabled) ---presence-penalty N repeat alpha presence penalty (default: 0.0, 0.0 = disabled) ---frequency-penalty N repeat alpha frequency penalty (default: 0.0, 0.0 = disabled) ---dry-multiplier N set DRY sampling multiplier (default: 0.0, 0.0 = disabled) ---dry-base N set DRY sampling base value (default: 1.75) ---dry-allowed-length N set allowed length for DRY sampling (default: 2) ---dry-penalty-last-n N set DRY penalty for the last n tokens (default: -1, 0 = disable, -1 = - context size) ---dry-sequence-breaker STRING add sequence breaker for DRY sampling, clearing out default breakers - ('\n', ':', '"', '*') in the process; use "none" to not use any - sequence breakers ---dynatemp-range N dynamic temperature range (default: 0.0, 0.0 = disabled) ---dynatemp-exp N dynamic temperature exponent (default: 1.0) ---mirostat N use Mirostat sampling. - Top K, Nucleus and Locally Typical samplers are ignored if used. - (default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0) ---mirostat-lr N Mirostat learning rate, parameter eta (default: 0.1) ---mirostat-ent N Mirostat target entropy, parameter tau (default: 5.0) --l, --logit-bias TOKEN_ID(+/-)BIAS modifies the likelihood of token appearing in the completion, - i.e. `--logit-bias 15043+1` to increase likelihood of token ' Hello', - or `--logit-bias 15043-1` to decrease likelihood of token ' Hello' ---grammar GRAMMAR BNF-like grammar to constrain generations (see samples in grammars/ - dir) (default: '') ---grammar-file FNAME file to read grammar from --j, --json-schema SCHEMA JSON schema to constrain generations (https://json-schema.org/), e.g. - `{}` for any JSON object - For schemas w/ external $refs, use --grammar + - example/json_schema_to_grammar.py instead --jf, --json-schema-file FILE File containing a JSON schema to constrain generations - (https://json-schema.org/), e.g. `{}` for any JSON object - For schemas w/ external $refs, use --grammar + - example/json_schema_to_grammar.py instead - - ------ example-specific params ----- - ---ctx-checkpoints, --swa-checkpoints N - max number of context checkpoints to create per slot (default: 8) - [(more info)](https://github.com/ggml-org/llama.cpp/pull/15293) - (env: LLAMA_ARG_CTX_CHECKPOINTS) ---cache-ram, -cram N set the maximum cache size in MiB (default: 8192, -1 - no limit, 0 - - disable) - [(more info)](https://github.com/ggml-org/llama.cpp/pull/16391) - (env: LLAMA_ARG_CACHE_RAM) ---no-context-shift disables context shift on infinite text generation (default: enabled) - (env: LLAMA_ARG_NO_CONTEXT_SHIFT) ---context-shift enables context shift on infinite text generation (default: disabled) - (env: LLAMA_ARG_CONTEXT_SHIFT) --r, --reverse-prompt PROMPT halt generation at PROMPT, return control in interactive mode --sp, --special special tokens output enabled (default: false) ---no-warmup skip warming up the model with an empty run ---spm-infill use Suffix/Prefix/Middle pattern for infill (instead of - Prefix/Suffix/Middle) as some models prefer this. (default: disabled) ---pooling {none,mean,cls,last,rank} pooling type for embeddings, use model default if unspecified - (env: LLAMA_ARG_POOLING) --cb, --cont-batching enable continuous batching (a.k.a dynamic batching) (default: enabled) - (env: LLAMA_ARG_CONT_BATCHING) --nocb, --no-cont-batching disable continuous batching - (env: LLAMA_ARG_NO_CONT_BATCHING) ---mmproj FILE path to a multimodal projector file. see tools/mtmd/README.md - note: if -hf is used, this argument can be omitted - (env: LLAMA_ARG_MMPROJ) ---mmproj-url URL URL to a multimodal projector file. see tools/mtmd/README.md - (env: LLAMA_ARG_MMPROJ_URL) ---no-mmproj explicitly disable multimodal projector, useful when using -hf - (env: LLAMA_ARG_NO_MMPROJ) ---no-mmproj-offload do not offload multimodal projector to GPU - (env: LLAMA_ARG_NO_MMPROJ_OFFLOAD) ---override-tensor-draft, -otd =,... - override tensor buffer type for draft model ---cpu-moe-draft, -cmoed keep all Mixture of Experts (MoE) weights in the CPU for the draft - model - (env: LLAMA_ARG_CPU_MOE_DRAFT) ---n-cpu-moe-draft, -ncmoed N keep the Mixture of Experts (MoE) weights of the first N layers in the - CPU for the draft model - (env: LLAMA_ARG_N_CPU_MOE_DRAFT) --a, --alias STRING set alias for model name (to be used by REST API) - (env: LLAMA_ARG_ALIAS) ---host HOST ip address to listen, or bind to an UNIX socket if the address ends - with .sock (default: 127.0.0.1) - (env: LLAMA_ARG_HOST) ---port PORT port to listen (default: 8080) - (env: LLAMA_ARG_PORT) ---path PATH path to serve static files from (default: ) - (env: LLAMA_ARG_STATIC_PATH) ---api-prefix PREFIX prefix path the server serves from, without the trailing slash - (default: ) - (env: LLAMA_ARG_API_PREFIX) ---no-webui Disable the Web UI (default: enabled) - (env: LLAMA_ARG_NO_WEBUI) ---embedding, --embeddings restrict to only support embedding use case; use only with dedicated - embedding models (default: disabled) - (env: LLAMA_ARG_EMBEDDINGS) ---reranking, --rerank enable reranking endpoint on server (default: disabled) - (env: LLAMA_ARG_RERANKING) ---api-key KEY API key to use for authentication (default: none) - (env: LLAMA_API_KEY) ---api-key-file FNAME path to file containing API keys (default: none) ---ssl-key-file FNAME path to file a PEM-encoded SSL private key - (env: LLAMA_ARG_SSL_KEY_FILE) ---ssl-cert-file FNAME path to file a PEM-encoded SSL certificate - (env: LLAMA_ARG_SSL_CERT_FILE) ---chat-template-kwargs STRING sets additional params for the json template parser - (env: LLAMA_CHAT_TEMPLATE_KWARGS) --to, --timeout N server read/write timeout in seconds (default: 600) - (env: LLAMA_ARG_TIMEOUT) ---threads-http N number of threads used to process HTTP requests (default: -1) - (env: LLAMA_ARG_THREADS_HTTP) ---cache-reuse N min chunk size to attempt reusing from the cache via KV shifting - (default: 0) - [(card)](https://ggml.ai/f0.png) - (env: LLAMA_ARG_CACHE_REUSE) ---metrics enable prometheus compatible metrics endpoint (default: disabled) - (env: LLAMA_ARG_ENDPOINT_METRICS) ---props enable changing global properties via POST /props (default: disabled) - (env: LLAMA_ARG_ENDPOINT_PROPS) ---slots enable slots monitoring endpoint (default: enabled) - (env: LLAMA_ARG_ENDPOINT_SLOTS) ---no-slots disables slots monitoring endpoint - (env: LLAMA_ARG_NO_ENDPOINT_SLOTS) ---slot-save-path PATH path to save slot kv cache (default: disabled) ---jinja use jinja template for chat (default: disabled) - (env: LLAMA_ARG_JINJA) ---reasoning-format FORMAT controls whether thought tags are allowed and/or extracted from the - response, and in which format they're returned; one of: - - none: leaves thoughts unparsed in `message.content` - - deepseek: puts thoughts in `message.reasoning_content` - - deepseek-legacy: keeps `` tags in `message.content` while - also populating `message.reasoning_content` - (default: auto) - (env: LLAMA_ARG_THINK) ---reasoning-budget N controls the amount of thinking allowed; currently only one of: -1 for - unrestricted thinking budget, or 0 to disable thinking (default: -1) - (env: LLAMA_ARG_THINK_BUDGET) ---chat-template JINJA_TEMPLATE set custom jinja chat template (default: template taken from model's - metadata) - if suffix/prefix are specified, template will be disabled - only commonly used templates are accepted (unless --jinja is set - before this flag): - list of built-in templates: - bailing, bailing-think, bailing2, chatglm3, chatglm4, chatml, - command-r, deepseek, deepseek2, deepseek3, exaone3, exaone4, falcon3, - gemma, gigachat, glmedge, gpt-oss, granite, grok-2, hunyuan-dense, - hunyuan-moe, kimi-k2, llama2, llama2-sys, llama2-sys-bos, - llama2-sys-strip, llama3, llama4, megrez, minicpm, mistral-v1, - mistral-v3, mistral-v3-tekken, mistral-v7, mistral-v7-tekken, monarch, - openchat, orion, phi3, phi4, rwkv-world, seed_oss, smolvlm, vicuna, - vicuna-orca, yandex, zephyr - (env: LLAMA_ARG_CHAT_TEMPLATE) ---chat-template-file JINJA_TEMPLATE_FILE - set custom jinja chat template file (default: template taken from - model's metadata) - if suffix/prefix are specified, template will be disabled - only commonly used templates are accepted (unless --jinja is set - before this flag): - list of built-in templates: - bailing, bailing-think, bailing2, chatglm3, chatglm4, chatml, - command-r, deepseek, deepseek2, deepseek3, exaone3, exaone4, falcon3, - gemma, gigachat, glmedge, gpt-oss, granite, grok-2, hunyuan-dense, - hunyuan-moe, kimi-k2, llama2, llama2-sys, llama2-sys-bos, - llama2-sys-strip, llama3, llama4, megrez, minicpm, mistral-v1, - mistral-v3, mistral-v3-tekken, mistral-v7, mistral-v7-tekken, monarch, - openchat, orion, phi3, phi4, rwkv-world, seed_oss, smolvlm, vicuna, - vicuna-orca, yandex, zephyr - (env: LLAMA_ARG_CHAT_TEMPLATE_FILE) ---no-prefill-assistant whether to prefill the assistant's response if the last message is an - assistant message (default: prefill enabled) - when this flag is set, if the last message is an assistant message - then it will be treated as a full message and not prefilled - - (env: LLAMA_ARG_NO_PREFILL_ASSISTANT) --sps, --slot-prompt-similarity SIMILARITY - how much the prompt of a request must match the prompt of a slot in - order to use that slot (default: 0.10, 0.0 = disabled) ---lora-init-without-apply load LoRA adapters without applying them (apply later via POST - /lora-adapters) (default: disabled) --td, --threads-draft N number of threads to use during generation (default: same as - --threads) --tbd, --threads-batch-draft N number of threads to use during batch and prompt processing (default: - same as --threads-draft) ---draft-max, --draft, --draft-n N number of tokens to draft for speculative decoding (default: 16) - (env: LLAMA_ARG_DRAFT_MAX) ---draft-min, --draft-n-min N minimum number of draft tokens to use for speculative decoding - (default: 0) - (env: LLAMA_ARG_DRAFT_MIN) ---draft-p-min P minimum speculative decoding probability (greedy) (default: 0.8) - (env: LLAMA_ARG_DRAFT_P_MIN) --cd, --ctx-size-draft N size of the prompt context for the draft model (default: 0, 0 = loaded - from model) - (env: LLAMA_ARG_CTX_SIZE_DRAFT) --devd, --device-draft comma-separated list of devices to use for offloading the draft model - (none = don't offload) - use --list-devices to see a list of available devices --ngld, --gpu-layers-draft, --n-gpu-layers-draft N - number of layers to store in VRAM for the draft model - (env: LLAMA_ARG_N_GPU_LAYERS_DRAFT) --md, --model-draft FNAME draft model for speculative decoding (default: unused) - (env: LLAMA_ARG_MODEL_DRAFT) ---spec-replace TARGET DRAFT translate the string in TARGET into DRAFT if the draft model and main - model are not compatible --mv, --model-vocoder FNAME vocoder model for audio generation (default: unused) ---tts-use-guide-tokens Use guide tokens to improve TTS word recall ---embd-gemma-default use default EmbeddingGemma model (note: can download weights from the - internet) ---fim-qwen-1.5b-default use default Qwen 2.5 Coder 1.5B (note: can download weights from the - internet) ---fim-qwen-3b-default use default Qwen 2.5 Coder 3B (note: can download weights from the - internet) ---fim-qwen-7b-default use default Qwen 2.5 Coder 7B (note: can download weights from the - internet) ---fim-qwen-7b-spec use Qwen 2.5 Coder 7B + 0.5B draft for speculative decoding (note: can - download weights from the internet) ---fim-qwen-14b-spec use Qwen 2.5 Coder 14B + 0.5B draft for speculative decoding (note: - can download weights from the internet) ---fim-qwen-30b-default use default Qwen 3 Coder 30B A3B Instruct (note: can download weights - from the internet) ---gpt-oss-20b-default use gpt-oss-20b (note: can download weights from the internet) ---gpt-oss-120b-default use gpt-oss-120b (note: can download weights from the internet) ---vision-gemma-4b-default use Gemma 3 4B QAT (note: can download weights from the internet) ---vision-gemma-12b-default use Gemma 3 12B QAT (note: can download weights from the internet) \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startBaseMedium.sh b/Services/llamacpp-swap/Scripts/startBaseMedium.sh deleted file mode 100755 index 85b8460..0000000 --- a/Services/llamacpp-swap/Scripts/startBaseMedium.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Report descrittivi: 0.6 ok; 0.55 più stabile -TEMP=${BASE_TEMP:-0.6} -exec /app/llama-server $BASE_MEDIUM_MODEL \ - -c $BASE_CONTEXT_SIZE -ngl $BASE_GPU_LAYERS -n $BASE_MAX_TOKENS \ - --temp $TEMP --top-p 0.9 --top-k 40 --repeat-penalty 1.1 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 600 --host 0.0.0.0 --port 8092 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startBaseMini.sh b/Services/llamacpp-swap/Scripts/startBaseMini.sh deleted file mode 100755 index 6c1da24..0000000 --- a/Services/llamacpp-swap/Scripts/startBaseMini.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $BASE_MINI_MODEL \ - -c 4096 -n 128 \ - --temp 0.2 --top-p 0.9 --top-k 40 --repeat-penalty 1.05 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 600 --host 0.0.0.0 --port 8091 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startBaseTop.sh b/Services/llamacpp-swap/Scripts/startBaseTop.sh deleted file mode 100755 index ff0fd17..0000000 --- a/Services/llamacpp-swap/Scripts/startBaseTop.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $BASE_TOP_MODEL \ - -c $BASE_CONTEXT_SIZE -ngl $BASE_GPU_LAYERS -n $BASE_MAX_TOKENS \ - --temp 0.5 --top-p 0.9 --top-k 40 --repeat-penalty 1.1 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 900 --host 0.0.0.0 --port 8093 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startChat.sh b/Services/llamacpp-swap/Scripts/startChat.sh deleted file mode 100755 index a4d98a6..0000000 --- a/Services/llamacpp-swap/Scripts/startChat.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Report descrittivi: 0.6 ok; 0.55 più stabile -TEMP=${GENERAL_TEMP:-0.6} -exec /app/llama-server $CHAT_MODEL \ - -c $GENERAL_CONTEXT_SIZE -ngl $GENERAL_GPU_LAYERS -n $GENERAL_MAX_TOKENS \ - --temp $TEMP --top-p 0.9 --top-k 40 --repeat-penalty 1.1 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 600 --host 0.0.0.0 --port 8093 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startCoder.sh b/Services/llamacpp-swap/Scripts/startCoder.sh deleted file mode 100755 index 5bc4729..0000000 --- a/Services/llamacpp-swap/Scripts/startCoder.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $CODER_MODEL \ - -c $CODER_CONTEXT_SIZE -n $CODER_MAX_TOKENS \ - --temp 0.3 --top-p 0.9 --top-k 40 --repeat-penalty 1.05 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 600 --host 0.0.0.0 --port 8094 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startCoderMedium.sh b/Services/llamacpp-swap/Scripts/startCoderMedium.sh deleted file mode 100755 index 0480fbf..0000000 --- a/Services/llamacpp-swap/Scripts/startCoderMedium.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Prefer Q6 + mmap; fallback to no-mmap only if explicitly requested -EXTRA="" -if [[ "$FORCE_NO_MMAP_CODER" == "1" ]]; then EXTRA="--no-mmap"; fi -exec /app/llama-server $CODER_MEDIUM_MODEL \ - -c $CODER_CONTEXT_SIZE -ngl $CODER_GPU_LAYERS -n $CODER_MAX_TOKENS \ - --temp 0.5 --top-p 0.9 --top-k 40 --repeat-penalty 1.1 $EXTRA \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 900 --host 0.0.0.0 --port 8095 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startCoderMini.sh b/Services/llamacpp-swap/Scripts/startCoderMini.sh deleted file mode 100755 index 2c1f13a..0000000 --- a/Services/llamacpp-swap/Scripts/startCoderMini.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $CODER_MINI_MODEL \ - -c 4096 -n 256 \ - --temp 0.3 --top-p 0.9 --top-k 40 --repeat-penalty 1.05 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --timeout 600 --host 0.0.0.0 --port 8094 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startCoderTop.sh b/Services/llamacpp-swap/Scripts/startCoderTop.sh deleted file mode 100755 index 55a04dd..0000000 --- a/Services/llamacpp-swap/Scripts/startCoderTop.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Large model: auto-select mmap based on GPU layers -# <= 45 layers: use mmap (less VRAM usage, faster startup) -# > 45 layers: disable mmap (avoids SVM limits) -LAYERS=${CODER_TOP_GPU_LAYERS:-55} -MMAP_OPT="" -if [ "$LAYERS" -gt 45 ]; then - MMAP_OPT="--no-mmap" - echo "Using --no-mmap (layers=$LAYERS > 45)" -else - echo "Using mmap (layers=$LAYERS <= 45)" -fi -exec /app/llama-server $CODER_TOP_MODEL \ - -c $CODER_CONTEXT_SIZE -ngl $LAYERS -n $CODER_MAX_TOKENS \ - --temp 0.45 --top-p 0.9 --top-k 40 --repeat-penalty 1.12 \ - $MMAP_OPT \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 1200 --host 0.0.0.0 --port 8096 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startEmbedding.sh b/Services/llamacpp-swap/Scripts/startEmbedding.sh deleted file mode 100755 index 0950ef4..0000000 --- a/Services/llamacpp-swap/Scripts/startEmbedding.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $EMBEDDING_MODEL \ - --embeddings --pooling mean \ - --flash-attn auto --threads -1 --threads-http -1 \ - --timeout 600 --host 0.0.0.0 --port 8096 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startEmbeddingFast.sh b/Services/llamacpp-swap/Scripts/startEmbeddingFast.sh deleted file mode 100755 index 854672d..0000000 --- a/Services/llamacpp-swap/Scripts/startEmbeddingFast.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $EMBEDDING_FAST_MODEL \ - --embeddings --pooling mean \ - --flash-attn auto --threads -1 --threads-http -1 \ - --timeout 600 --host 0.0.0.0 --port 8095 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startEmbeddingMedium.sh b/Services/llamacpp-swap/Scripts/startEmbeddingMedium.sh deleted file mode 100755 index 6b6a116..0000000 --- a/Services/llamacpp-swap/Scripts/startEmbeddingMedium.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $EMBEDDING_MEDIUM_MODEL \ - --embeddings --pooling mean \ - --flash-attn auto --threads -1 --threads-http -1 \ - --timeout 600 --host 0.0.0.0 --port 8098 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startEmbeddingMini.sh b/Services/llamacpp-swap/Scripts/startEmbeddingMini.sh deleted file mode 100755 index 108808c..0000000 --- a/Services/llamacpp-swap/Scripts/startEmbeddingMini.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $EMBEDDING_MINI_MODEL \ - --embeddings --pooling mean \ - --flash-attn auto --threads -1 --threads-http -1 \ - --timeout 600 --host 0.0.0.0 --port 8097 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startEmbeddingTop.sh b/Services/llamacpp-swap/Scripts/startEmbeddingTop.sh deleted file mode 100755 index f19476c..0000000 --- a/Services/llamacpp-swap/Scripts/startEmbeddingTop.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $EMBEDDING_TOP_MODEL \ - --embeddings --pooling mean \ - --flash-attn auto --threads -1 --threads-http -1 \ - --timeout 600 --host 0.0.0.0 --port 8099 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startGeneral.sh b/Services/llamacpp-swap/Scripts/startGeneral.sh deleted file mode 100755 index d622050..0000000 --- a/Services/llamacpp-swap/Scripts/startGeneral.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Report descrittivi: 0.6 ok; 0.55 più stabile -TEMP=${GENERAL_TEMP:-0.6} -exec /app/llama-server $GENERAL_MODEL \ - -c $GENERAL_CONTEXT_SIZE -ngl $GENERAL_GPU_LAYERS -n $GENERAL_MAX_TOKENS \ - --temp $TEMP --top-p 0.9 --top-k 40 --repeat-penalty 1.1 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 600 --host 0.0.0.0 --port 8092 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/startGeneralFast.sh b/Services/llamacpp-swap/Scripts/startGeneralFast.sh deleted file mode 100755 index 89f15c8..0000000 --- a/Services/llamacpp-swap/Scripts/startGeneralFast.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -exec /app/llama-server $GENERAL_FAST_MODEL \ - -c $GENERAL_CONTEXT_SIZE -n 128 \ - --temp 0.6 --top-p 0.9 --top-k 40 --repeat-penalty 1.05 \ - --flash-attn auto --threads -1 --threads-batch -1 --threads-http -1 \ - --jinja \ - --timeout 600 --host 0.0.0.0 --port 8091 & -PID=$! - -cleanup() { - echo "Stopping llama-server..." - kill $PID 2>/dev/null - wait $PID 2>/dev/null - exit 0 -} - -trap cleanup SIGTERM SIGINT - -wait $PID \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopBaseMedium.sh b/Services/llamacpp-swap/Scripts/stopBaseMedium.sh deleted file mode 100755 index 1bac166..0000000 --- a/Services/llamacpp-swap/Scripts/stopBaseMedium.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8092" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopBaseMini.sh b/Services/llamacpp-swap/Scripts/stopBaseMini.sh deleted file mode 100755 index e2372cb..0000000 --- a/Services/llamacpp-swap/Scripts/stopBaseMini.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8091" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopBaseTop.sh b/Services/llamacpp-swap/Scripts/stopBaseTop.sh deleted file mode 100755 index e8f0af9..0000000 --- a/Services/llamacpp-swap/Scripts/stopBaseTop.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8093" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopChat.sh b/Services/llamacpp-swap/Scripts/stopChat.sh deleted file mode 100755 index 4f08201..0000000 --- a/Services/llamacpp-swap/Scripts/stopChat.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Stop llama-server per DuckAi-Chat -pkill -f "llama-server.*--port 8093" \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopCoder.sh b/Services/llamacpp-swap/Scripts/stopCoder.sh deleted file mode 100755 index b746e7d..0000000 --- a/Services/llamacpp-swap/Scripts/stopCoder.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Stop llama-server per DuckAi-Coder -pkill -f "llama-server.*--port 8094" \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopCoderMedium.sh b/Services/llamacpp-swap/Scripts/stopCoderMedium.sh deleted file mode 100755 index 0bcc58f..0000000 --- a/Services/llamacpp-swap/Scripts/stopCoderMedium.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8095" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopCoderMini.sh b/Services/llamacpp-swap/Scripts/stopCoderMini.sh deleted file mode 100755 index ac34c3c..0000000 --- a/Services/llamacpp-swap/Scripts/stopCoderMini.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8094" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopCoderTop.sh b/Services/llamacpp-swap/Scripts/stopCoderTop.sh deleted file mode 100755 index 67c94d1..0000000 --- a/Services/llamacpp-swap/Scripts/stopCoderTop.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8096" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopEmbedding.sh b/Services/llamacpp-swap/Scripts/stopEmbedding.sh deleted file mode 100755 index 6ea4688..0000000 --- a/Services/llamacpp-swap/Scripts/stopEmbedding.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Stop llama-server per DuckAi-Embedding -pkill -f "llama-server.*--port 8096" \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopEmbeddingFast.sh b/Services/llamacpp-swap/Scripts/stopEmbeddingFast.sh deleted file mode 100755 index 1758b7d..0000000 --- a/Services/llamacpp-swap/Scripts/stopEmbeddingFast.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Stop llama-server per DuckAi-EmbeddingFast -pkill -f "llama-server.*--port 8095" \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopEmbeddingMedium.sh b/Services/llamacpp-swap/Scripts/stopEmbeddingMedium.sh deleted file mode 100755 index 3f8eacc..0000000 --- a/Services/llamacpp-swap/Scripts/stopEmbeddingMedium.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8098" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopEmbeddingMini.sh b/Services/llamacpp-swap/Scripts/stopEmbeddingMini.sh deleted file mode 100755 index 54d1707..0000000 --- a/Services/llamacpp-swap/Scripts/stopEmbeddingMini.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8097" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopEmbeddingTop.sh b/Services/llamacpp-swap/Scripts/stopEmbeddingTop.sh deleted file mode 100755 index f2dcf3d..0000000 --- a/Services/llamacpp-swap/Scripts/stopEmbeddingTop.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pkill -f "llama-server.*8099" || true \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopGeneral.sh b/Services/llamacpp-swap/Scripts/stopGeneral.sh deleted file mode 100755 index 2f4fda0..0000000 --- a/Services/llamacpp-swap/Scripts/stopGeneral.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Stop llama-server per DuckAi-General -pkill -f "llama-server.*--port 8092" \ No newline at end of file diff --git a/Services/llamacpp-swap/Scripts/stopGeneralFast.sh b/Services/llamacpp-swap/Scripts/stopGeneralFast.sh deleted file mode 100755 index 754410c..0000000 --- a/Services/llamacpp-swap/Scripts/stopGeneralFast.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Stop llama-server per DuckAi-GeneralFast -pkill -f "llama-server.*--port 8091" \ No newline at end of file diff --git a/Services/llamacpp-swap/config.preset.yaml b/Services/llamacpp-swap/config.preset.yaml deleted file mode 100644 index d096317..0000000 --- a/Services/llamacpp-swap/config.preset.yaml +++ /dev/null @@ -1,59 +0,0 @@ -logLevel: info -healthCheckTimeout: 120 - -models: - DuckAi-GeneralFast: - proxy: http://localhost:8091 - cmd: /app/Scripts/startGeneralFast.sh - cmdStop: /app/Scripts/stopGeneralFast.sh - checkEndpoint: /health - - DuckAi-General: - proxy: http://localhost:8092 - cmd: /app/Scripts/startGeneral.sh - cmdStop: /app/Scripts/stopGeneral.sh - checkEndpoint: /health - ttl: 600 - - DuckAi-Chat: - proxy: http://localhost:8093 - cmd: /app/Scripts/startChat.sh - cmdStop: /app/Scripts/stopChat.sh - checkEndpoint: /health - ttl: 600 - - DuckAi-Coder: - proxy: http://localhost:8094 - cmd: /app/Scripts/startCoder.sh - cmdStop: /app/Scripts/stopCoder.sh - checkEndpoint: /health - ttl: 600 - - DuckAi-EmbeddingFast: - proxy: http://localhost:8095 - cmd: /app/Scripts/startEmbeddingFast.sh - cmdStop: /app/Scripts/stopEmbeddingFast.sh - checkEndpoint: /health - ttl: 600 - - DuckAi-Embedding: - proxy: http://localhost:8096 - cmd: /app/Scripts/startEmbedding.sh - cmdStop: /app/Scripts/stopEmbedding.sh - checkEndpoint: /health - ttl: 600 - -groups: - default-models: - swap: false - exclusive: false - persistent: true - members: - - DuckAi-GeneralFast - - DuckAi-Chat - - DuckAi-Embedding - -hooks: - on_startup: - preload: - - DuckAi-GeneralFast diff --git a/Services/llamacpp-swap/entrypoint.sh b/Services/llamacpp-swap/entrypoint.sh deleted file mode 100644 index 60a33c7..0000000 --- a/Services/llamacpp-swap/entrypoint.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -CONFIG_FILE="/app/config.yaml" -PRESET_FILE="/app/config.preset.yaml" - -echo "Checking configuration..." - -# Se il file non esiste o è vuoto o non contiene 'models:', usa il preset -if [ ! -f "$CONFIG_FILE" ] || [ ! -s "$CONFIG_FILE" ] || ! grep -q "models:" "$CONFIG_FILE" 2>/dev/null; then - echo "Config file missing, empty, or invalid. Copying from preset..." - cp "$PRESET_FILE" "$CONFIG_FILE" - echo "Config file populated from preset." -else - echo "Config file found and valid." -fi - -exec /app/llama-swap -config "$CONFIG_FILE" -listen :8080 diff --git a/Services/llamacpp-swap/lamacpp-swap-nginx.conf b/Services/llamacpp-swap/lamacpp-swap-nginx.conf deleted file mode 100644 index 444b360..0000000 --- a/Services/llamacpp-swap/lamacpp-swap-nginx.conf +++ /dev/null @@ -1,101 +0,0 @@ -# Template Nginx per servizi containerizzati -# Sostituisci [DOMAIN], [UPSTREAM_NAME], [UPSTREAM_SERVER] con i valori appropriati - -server { - listen 80; - server_name models.ai.duckpage.net; - return 301 https://$server_name$request_uri; -} - -server { - listen 443 ssl; - listen [::]:443 ssl; - server_name models.ai.duckpage.net; - charset utf-8; - keepalive_timeout 70; - - # SSL - ssl_certificate /etc/nginx/ssl/live/ai.duckpage.net/fullchain.pem; - ssl_certificate_key /etc/nginx/ssl/live/ai.duckpage.net/privkey.pem; - - # Improve HTTPS performance with session resumption - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - - # SSL Protocols and Ciphers - ssl_protocols TLSv1.3; - ssl_prefer_server_ciphers off; - ssl_dhparam /etc/nginx/ssl/dhparam.pem; - ssl_ecdh_curve secp521r1:secp384r1; - - # Security Headers - add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; - add_header X-Frame-Options SAMEORIGIN always; - add_header X-Content-Type-Options nosniff always; - add_header X-Xss-Protection "1; mode=block" always; - - # OCSP Stapling - ssl_stapling on; - ssl_stapling_verify on; - ssl_trusted_certificate /etc/nginx/ssl/live/ai.duckpage.net/fullchain.pem; - resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] valid=300s; - resolver_timeout 5s; - - client_max_body_size 512M; - client_body_buffer_size 128k; - - # Gzip - gzip_types text/plain text/xml text/css application/xhtml+xml application/xml image/svg+xml application/rss+xml application/atom_xml application/javascript application/x-javascript application/x-httpd-php application/x-httpd-fastphp application/x-httpd-eruby; - - - # Main Proxy - location /v1 { - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - - proxy_connect_timeout 600; - proxy_send_timeout 600; - proxy_read_timeout 600; - send_timeout 600; - - proxy_redirect off; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_pass http://llamacpp:8080/v1; - } - - location / { - # Allow specific IPs (replace with your actual IPs) - allow 127.0.0.1; - allow ::1; - allow 10.50.210.0/24; - allow 10.0.80.0/24; - # Add more allow lines for specific IPs, e.g., allow 192.168.1.0/24; - deny all; - - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - - proxy_connect_timeout 600; - proxy_send_timeout 600; - proxy_read_timeout 600; - send_timeout 600; - - proxy_redirect off; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_pass http://llamacpp:8080; - } - - location ~ /\.ht { - deny all; - } -} diff --git a/Services/llamacpp-swap/llama-swap-vulkan.Containerfile b/Services/llamacpp-swap/llama-swap-vulkan.Containerfile deleted file mode 100644 index 7972f99..0000000 --- a/Services/llamacpp-swap/llama-swap-vulkan.Containerfile +++ /dev/null @@ -1,121 +0,0 @@ -### LLaMACpp Builder Container with Vulkan for GPUs -### Multi-stage: download stage with pre-built binaries, runtime stage with only runtime libraries -### -### BUILD: podman build -t llamacpp-swap:vulkan-amd64 -f llama-swap-vulkan.Containerfile . -### Export: podman save -o /home/duckpage/llamacpp-swap-vulkan-amd64.tar localhost/llamacpp-swap:vulkan-amd64 - - -ARG UBUNTU_VERSION=24.04 - -### Download image -FROM ubuntu:${UBUNTU_VERSION} AS download - -RUN apt-get update \ - && apt-get install -y curl unzip grep sed \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /tmp - -RUN VERSION=$(curl -s -I https://github.com/ggml-org/llama.cpp/releases/latest | grep -i location | sed 's|.*/tag/||' | tr -d '\r') \ - && echo "Last llama.cpp version: $VERSION" \ - && curl -L https://github.com/ggml-org/llama.cpp/releases/download/${VERSION}/llama-${VERSION}-bin-ubuntu-vulkan-x64.zip -o llama.zip \ - && unzip llama.zip \ - && rm llama.zip \ - && if [ -d llama-* ]; then mv llama-*/* . && rmdir llama-*; elif [ -d build ]; then mv build/* . && rmdir build; fi \ - && if [ -d bin ]; then mv bin/* . && rmdir bin; fi # flatten further - -RUN mkdir -p /app/lib /app/full \ - && find . -name "*.so" -exec cp {} /app/lib \; \ - && cp -r * /app/full 2>/dev/null || true \ - && ls -la /app/full # list contents - -## Base image -FROM ubuntu:${UBUNTU_VERSION} AS base - -RUN apt-get update \ - && apt-get install -y libgomp1 curl nano ca-certificates wget\ - && apt autoremove -y \ - && apt clean -y \ - && rm -rf /tmp/* /var/tmp/* \ - && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ - && find /var/cache -type f -delete - -COPY --from=download /app/lib/ /app - -### Full -FROM base AS full - -COPY --from=download /app/full /app - -RUN chmod +x /app/llama-server - -WORKDIR /app - -RUN apt-get update \ - && apt-get install -y \ - libvulkan-dev \ - git \ - python3-pip \ - python3 \ - python3-wheel\ - && pip install --break-system-packages --upgrade setuptools \ - && pip install --break-system-packages -U "huggingface_hub[cli]" \ - && if [ -f requirements.txt ]; then pip install --break-system-packages -r requirements.txt; fi \ - && apt autoremove -y \ - && apt clean -y \ - && rm -rf /tmp/* /var/tmp/* \ - && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ - && find /var/cache -type f -delete - -# -------- Model args (prefer Q6 to keep mmap on and avoid load issues) -------- -ARG GENERAL_FAST_MODEL="-m models/gemma-3-1b-it-Q5_K_M.gguf" -ARG GENERAL_MODEL="-m models/gpt-oss-20b-Q4_K_M.gguf" - -ARG CHAT_MODEL="-m models/Qwen3-VL-30B-A3B-Q4_K_S.gguf" - -ARG CODER_MODEL="-m models/Qwen3-Coder-30B-A3B-Instruct-Q6_K.gguf" - -ARG EMBEDDING_FAST_MODEL="-m models/embeddinggemma-300M-Q8_0.gguf" -ARG EMBEDDING_MODEL="-m models/bge-code-v1-q6_k.gguf" - -# -------- Runtime defaults -------- -ARG GENERAL_CONTEXT_SIZE=16384 -ARG GENERAL_GPU_LAYERS=99 -ARG GENERAL_MAX_TOKENS=512 - -ARG CODER_CONTEXT_SIZE=131072 -ARG CODER_GPU_LAYERS=99 -ARG CODER_MAX_TOKENS=512 - -ENV GENERAL_FAST_MODEL=${GENERAL_FAST_MODEL} -ENV GENERAL_MODEL=${GENERAL_MODEL} -ENV CODER_MODEL=${CODER_MODEL} -ENV EMBEDDING_FAST_MODEL=${EMBEDDING_FAST_MODEL} -ENV EMBEDDING_MODEL=${EMBEDDING_MODEL} - -ENV GENERAL_CONTEXT_SIZE=${GENERAL_CONTEXT_SIZE} -ENV GENERAL_GPU_LAYERS=${GENERAL_GPU_LAYERS} -ENV GENERAL_MAX_TOKENS=${GENERAL_MAX_TOKENS} -ENV CODER_CONTEXT_SIZE=${CODER_CONTEXT_SIZE} -ENV CODER_GPU_LAYERS=${CODER_GPU_LAYERS} -ENV CODER_MAX_TOKENS=${CODER_MAX_TOKENS} - -# -------- llama-swap -------- -RUN curl -L https://github.com/mostlygeek/llama-swap/releases/download/v165/llama-swap_165_linux_amd64.tar.gz -o /tmp/llama-swap.tar.gz \ - && tar -xzf /tmp/llama-swap.tar.gz -C /app \ - && rm /tmp/llama-swap.tar.gz - -# -------- start/stop scripts -------- -# Nota: usiamo --threads -1 --threads-batch -1 per lasciare a llama.cpp l'autotuning - -COPY ./Scripts/ /app/Scripts/ -RUN chmod +x /app/Scripts/*.sh - -# -------- Copy preset config file -------- -COPY ./config.preset.yaml /app/config.preset.yaml - -# -------- Copy entrypoint script -------- -COPY ./entrypoint.sh /app/entrypoint.sh -RUN chmod +x /app/entrypoint.sh - -ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/Services/llamacpp-swap/llamacpp-swap.container b/Services/llamacpp-swap/llamacpp-swap.container deleted file mode 100644 index cfcc4ea..0000000 --- a/Services/llamacpp-swap/llamacpp-swap.container +++ /dev/null @@ -1,54 +0,0 @@ -[Unit] -Name=llamacpp - -[Container] -ContainerName=llamacpp -Image=localhost/llamacpp:vulkan-amd64 -Network=internal.network - -PublishPort=8080:8080 - -# ROCm -AddDevice=/dev/kfd -AddDevice=/dev/dri -PodmanArgs=--userns=keep-id --group-add=keep-groups --ipc=host -SecurityLabelType=container_runtime_t - -# ROCm tuning -#Environment=HSA_OVERRIDE_GFX_VERSION=11.5.1 -#Environment=ROCR_VISIBLE_DEVICES=0 -#Environment=GPU_TARGETS=gfx1151 - -# API Key -#Environment=LLAMA_API_KEY="" - -# Models -Environment=GENERAL_FAST_MODEL="-m models/gemma-3-1b-it-Q5_K_M.gguf" -Environment=GENERAL_MODEL="-m models/gpt-oss-20b-Q4_K_M.gguf" - -Environment=CHAT_MODEL="-m models/Qwen3-VL-30B-A3B-Q4_K_S.gguf" - -Environment=CODER_MODEL="-m models/Qwen3-Coder-30B-A3B-Instruct-Q6_K.gguf" - -Environment=EMBEDDING_FAST_MODEL="-m models/embeddinggemma-300M-Q8_0.gguf" -Environment=EMBEDDING_MODEL="-m models/bge-code-v1-q6_k.gguf" - -Environment=GENERAL_CONTEXT_SIZE=262144 -Environment=GENERAL_GPU_LAYERS=99 -Environment=GENERAL_MAX_TOKENS=512 - -Environment=CODER_CONTEXT_SIZE=131072 -Environment=CODER_GPU_LAYERS=99 -Environment=CODER_MAX_TOKENS=512 - -# Mount points -Volume=/srv/containers/aitools/.cache:/home/ubuntu/.cache -Volume=/srv/containers/aitools/models:/app/models -Volume=/srv/containers/aitools/llamacpp_config.yaml:/app/config.yaml - -[Service] -Restart=on-failure -TimeoutStartSec=15m - -[Install] -WantedBy=multi-user.target default.target diff --git a/Services/odoo/INSTALL.md b/Services/odoo/INSTALL.md deleted file mode 100644 index ccc912a..0000000 --- a/Services/odoo/INSTALL.md +++ /dev/null @@ -1,159 +0,0 @@ -### Installazione ODOO - -``` -$ apt install -y git python3 python3-dev python3-venv postgresql postgresql-contrib libxml2-dev libxslt1-dev libjpeg-dev libpng-dev libopenjp2-7-dev libtiff-dev build-essential libssl-dev libffi-dev libpq-dev libldap2-dev libsasl2-dev - -``` -`$ sudo apt install unixodbc unixodbc-dev` - -``` -$ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb -$ apt install ./wkhtmltox_0.12.6.1-3.bookworm_amd64.deb -``` - -`$ sudo useradd -m -d /var/lib/odoo -U -r -s /bin/bash odoo` - -``` -$ cd /var/lib/odoo -$ sudo -u odoo git clone https://github.com/odoo/odoo.git --depth 1 --branch 19.0 odoo-server -$ sudo -u odoo python3 -m venv venv -``` - -``` -$ sudo -u odoo bash -c 'source /var/lib/odoo/venv/bin/activate && pip install -r /var/lib/odoo/odoo-server/requirements.txt && pip install phonenumbers pyodbc' - -``` - -`$ sudo mkdir -p /etc/odoo` - -``` -$ sudo touch /etc/odoo/odoo.conf -$ sudo chown odoo:odoo /etc/odoo/odoo.conf -$ sudo chmod 640 /etc/odoo/odoo.conf -$ nano /etc/odoo/odoo.conf -``` - -``` -[options] -; Server Configuration -admin_passwd = Password123; -db_host = localhost -db_port = 5432 -db_user = odoo -db_password = odoo - -; File Paths -addons_path = /var/lib/odoo/odoo-server/addons,/var/lib/odoo/custom_addons -data_dir = /var/lib/odoo/.local/share/Odoo - -; Logging -log_file = /var/log/odoo/odoo.log -log_level = info - -; Workers (optional, for production) -workers = 4 -longpolling_port = 8072 - -; Other Settings -max_cron_threads = 2 -``` - - -``` -$ sudo mkdir -p /var/lib/odoo/custom_addons -$ sudo mkdir -p /var/lib/odoo/.local/share/Odoo -$ sudo mkdir -p /var/log/odoo -$ sudo chown -R odoo:odoo /var/lib/odoo -$ sudo chown -R odoo:odoo /var/log/odoo -$ sudo chmod -R 755 /var/lib/odoo -$ sudo chmod -R 755 /var/log/odoo -$ sudo chown -R odoo:odoo /var/lib/odoo/.local/share/Odoo -$ sudo chmod -R 755 /var/lib/odoo/.local/share/Odoo -``` - -`$ sudo nano /etc/systemd/system/odoo.service` - -``` -[Unit] -Description=Odoo ERP Service -Documentation=https://www.odoo.com -After=network-online.target postgresql.service -Wants=network-online.target - -[Service] -Type=simple -SyslogIdentifier=odoo -Restart=always -RestartSec=10 -User=odoo -Group=odoo -WorkingDirectory=/var/lib/odoo/odoo-server - -; Attivare il virtual environment e avviare Odoo -Environment="PATH=/var/lib/odoo/venv/bin" -ExecStart=/var/lib/odoo/venv/bin/python3 /var/lib/odoo/odoo-server/odoo-bin \ - -c /etc/odoo/odoo.conf - -; Logging -StandardOutput=journal -StandardError=journal - -; Security & Limits -LimitNOFILE=65535 -LimitNPROC=4096 - -[Install] -WantedBy=multi-user.target - -``` - - - -``` -$ sudo systemctl daemon-reload -$ sudo systemctl enable odoo -$ sudo systemctl start odoo - -``` - - - -#### ODBC - -``` -$ nano odbc.sh - -``` -``` -#!/bin/bash - -# Estrai la versione principale di Debian (es. 11, 12) -DEBIAN_VERSION=$(grep '^VERSION_ID=' /etc/os-release | cut -d'"' -f2 | cut -d'.' -f1) - -# Verifica supporto (Debian 9–13) -if ! [[ " 9 10 11 12 13 " == *" $DEBIAN_VERSION "* ]]; then - echo "Debian $DEBIAN_VERSION is not currently supported." - exit 1 -fi - -# Scarica il pacchetto Microsoft repo -curl -sSL -O "https://packages.microsoft.com/config/debian/$DEBIAN_VERSION/packages-microsoft-prod.deb" - -# Installa il pacchetto -sudo dpkg -i packages-microsoft-prod.deb -rm packages-microsoft-prod.deb - -# Aggiorna e installa ODBC -sudo apt-get update -sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - -# Optional: mssql-tools -sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 -echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc -source ~/.bashrc - -# Optional: headers ODBC e Kerberos -sudo apt-get install -y unixodbc-dev -sudo apt-get install -y libgssapi-krb5-2 -``` -`$ bash odbc.sh` \ No newline at end of file diff --git a/Services/odoo/odoo-oca.Containerfile b/Services/odoo/odoo-oca.Containerfile deleted file mode 100644 index 9387df7..0000000 --- a/Services/odoo/odoo-oca.Containerfile +++ /dev/null @@ -1,230 +0,0 @@ -# syntax=docker/dockerfile:1.9 -# Build: podman build -t odoo-oca:18 -f odoo-oca.ContainerFile . -# Export: podman save -o /home/badstorm/odoo-oca-18.tar localhost/odoo-oca:18 - -# syntax=docker/dockerfile:1.9 -# Build: podman build -t odoo:18-debian13 -f odoo.ContainerFile . - -FROM debian:13-slim - -ENV DEBIAN_FRONTEND=noninteractive -ENV ODOO_BRANCH=18.0 -ENV VENV_PATH=/opt/odoo/venv18 - -ENV DB_HOST=postgres -ENV DB_PORT=5432 -ENV DB_USER=odoo -ENV DB_PASSWORD=odoo -ENV ADMIN_PASSWD=my_admin_password - -RUN apt-get update && apt-get install -y --no-install-recommends \ - git wget curl ca-certificates \ - python3 python3.13-dev python3-dev python3-venv python3-pip \ - build-essential gcc g++ make pkg-config \ - postgresql-client xfonts-base \ - libxml2-dev libxslt1-dev zlib1g-dev \ - libjpeg-dev libpng-dev libopenjp2-7-dev libtiff-dev \ - libfreetype6-dev liblcms2-dev \ - libssl-dev libffi-dev libpq-dev libldap2-dev libsasl2-dev \ - && rm -rf /var/lib/apt/lists/* - -RUN useradd -m -d /opt/odoo -U -r -s /bin/bash odoo - -RUN mkdir -p \ - /opt/odoo/addons18/OCA \ - /opt/odoo/addons18/custom \ - /opt/odoo/data/filestore \ - /opt/odoo/log \ - /etc/odoo \ - && chown -R odoo:odoo /opt/odoo /etc/odoo - -WORKDIR /opt/odoo - -RUN git clone https://github.com/OCA/OCB.git \ - --depth=1 --branch=${ODOO_BRANCH} --single-branch \ - /opt/odoo/18.0 - -RUN set -eux; \ - for repo in \ - account-analytic \ - account-budgeting \ - account-closing \ - account-financial-reporting \ - account-financial-tools \ - account-fiscal-rule \ - account-invoice-reporting \ - account-invoicing \ - account-payment \ - account-reconcile \ - agreement \ - ai \ - automation \ - bank-payment \ - bank-payment-alternative \ - bank-statement-import \ - brand \ - calendar \ - commission \ - community-data-files \ - connector \ - connector-interfaces \ - connector-telephony \ - contract \ - credit-control \ - crm \ - currency \ - data-protection \ - ddmrp \ - delivery-carrier \ - dms \ - donation \ - e-commerce \ - edi \ - edi-framework \ - edi-voxel \ - event \ - field-service \ - fleet \ - geospatial \ - helpdesk \ - hr \ - hr-attendance \ - hr-expense \ - hr-holidays \ - interface-github \ - intrastat-extrastat \ - iot \ - knowledge \ - l10n-belgium \ - l10n-brazil \ - l10n-colombia \ - l10n-ecuador \ - l10n-finland \ - l10n-france \ - l10n-germany \ - l10n-iran \ - l10n-italy \ - l10n-japan \ - l10n-mexico \ - l10n-netherlands \ - l10n-portugal \ - l10n-romania \ - l10n-spain \ - l10n-switzerland \ - l10n-thailand \ - l10n-usa \ - mail \ - maintenance \ - management-system \ - manufacture \ - manufacture-reporting \ - margin-analysis \ - mass-mailing \ - mis-builder \ - multi-company \ - operating-unit \ - partner-contact \ - payroll \ - pms \ - pos \ - product-attribute \ - product-configurator \ - product-pack \ - product-variant \ - project \ - purchase-reporting \ - purchase-workflow \ - queue \ - repair \ - reporting-engine \ - report-print-send \ - rest-framework \ - rma \ - sale-blanket \ - sale-channel \ - sale-promotion \ - sale-reporting \ - sale-workflow \ - search-engine \ - server-auth \ - server-backend \ - server-brand \ - server-env \ - server-tools \ - server-ux \ - shopfloor-app \ - sign \ - social \ - spreadsheet \ - stock-logistics-availability \ - stock-logistics-barcode \ - stock-logistics-interfaces \ - stock-logistics-orderpoint \ - stock-logistics-putaway \ - stock-logistics-release-channel \ - stock-logistics-reporting \ - stock-logistics-request \ - stock-logistics-reservation \ - stock-logistics-shopfloor \ - stock-logistics-tracking \ - stock-logistics-transport \ - stock-logistics-warehouse \ - stock-logistics-workflow \ - storage \ - survey \ - timesheet \ - vertical-association \ - web \ - web-api \ - web-api-contrib \ - website \ - ; do \ - git clone https://github.com/OCA/${repo}.git \ - --depth=1 \ - --branch=${ODOO_BRANCH} \ - --single-branch \ - /opt/odoo/addons18/OCA/${repo}; \ - done - -RUN git clone https://gitlab.com/PNLUG/Odoo/repository/iso_addons.git \ - --depth=1 --branch=${ODOO_BRANCH} --single-branch \ - /opt/odoo/addons18/custom/iso_addons - -RUN python3 -m venv ${VENV_PATH} - -RUN ${VENV_PATH}/bin/pip install --upgrade pip setuptools wheel \ - && ${VENV_PATH}/bin/pip install \ - pypdf phonenumbers asn1crypto codicefiscale unidecode psycopg2-binary \ - paramiko==3.5.1 pysftp packaging pyPDF2 cryptography \ - -r /opt/odoo/18.0/requirements.txt \ - -r /opt/odoo/addons18/OCA/l10n-italy/requirements.txt - -RUN ADDONS_PATH="/opt/odoo/18.0/addons,/opt/odoo/18.0/odoo/addons"; \ - for d in /opt/odoo/addons18/OCA/*; do \ - ADDONS_PATH="${ADDONS_PATH},${d}"; \ - done; \ - ADDONS_PATH="${ADDONS_PATH},/opt/odoo/addons18/custom/iso_addons"; \ - printf "[options]\n\ -admin_passwd = ${ADMIN_PASSWD}\n\ -db_host = ${DB_HOST}\n\ -db_port = ${DB_PORT}\n\ -db_user = ${DB_USER}\n\ -db_password = ${DB_PASSWORD}\n\ -addons_path = ${ADDONS_PATH}\n\ -logfile = /opt/odoo/log/odoo.log\n\ -data_dir = /opt/odoo/data\n\ -proxy_mode = True\n\ -" > /etc/odoo/odoo18.conf \ - && chown -R odoo:odoo /opt/odoo /etc/odoo \ - && chmod 640 /etc/odoo/odoo18.conf \ - && chmod -R 775 /opt/odoo/data /opt/odoo/log - -EXPOSE 8069 8072 - -VOLUME ["/opt/odoo/addons18/custom", "/opt/odoo/data", "/opt/odoo/log"] - -USER odoo - -WORKDIR /opt/odoo/18.0 - -CMD ["/opt/odoo/venv18/bin/python", "/opt/odoo/18.0/odoo-bin", "-c", "/etc/odoo/odoo18.conf"] \ No newline at end of file diff --git a/Services/odoo/odoo.ContainerFile b/Services/odoo/odoo.ContainerFile deleted file mode 100644 index 32f34c0..0000000 --- a/Services/odoo/odoo.ContainerFile +++ /dev/null @@ -1,93 +0,0 @@ -# syntax=docker/dockerfile:1.9 -# Build: podman build -t odoo:19-amd64 -f odoo.ContainerFile . -# Export: podman save -o /home/badstorm/odoo-19-amd64.tar localhost/odoo:19-amd64 -# Podman Containerfile for Odoo 19 - -# Use Debian Trixie as base -FROM debian:13-slim - -# Avoid interactive prompts during package installation -ENV DEBIAN_FRONTEND=noninteractive - -# Install system dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - git \ - python3 \ - python3-dev \ - python3-venv \ - libxml2-dev \ - libxslt1-dev \ - libjpeg-dev \ - libpng-dev \ - libopenjp2-7-dev \ - libtiff-dev \ - build-essential \ - libssl-dev \ - libffi-dev \ - libpq-dev \ - postgresql-client \ - libldap2-dev \ - libsasl2-dev \ - curl \ - && rm -rf /var/lib/apt/lists/* - -# Install wkhtmltopdf -RUN curl -sSL -o /tmp/wkhtmltox.deb "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb" \ - && apt-get update && apt-get install -y /tmp/wkhtmltox.deb \ - && rm -rf /var/lib/apt/lists/* /tmp/wkhtmltox.deb - -# Create odoo user -RUN useradd -m -d /opt/odoo -U -r -s /bin/bash odoo - -# Create necessary directories -RUN mkdir -p /opt/odoo/custom_addons \ - && mkdir -p /opt/odoo/data \ - && mkdir -p /opt/odoo/data/filestore \ - && mkdir -p /opt/odoo/log \ - && chown -R odoo:odoo /opt/odoo \ - && chown -R odoo:odoo /opt/odoo/log \ - && chmod -R 755 /opt/odoo \ - && chmod -R 775 /opt/odoo/data \ - && chmod -R 775 /opt/odoo/log - -# Clone Odoo repository -WORKDIR /opt/odoo -RUN git clone https://github.com/odoo/odoo.git --depth 1 --branch 19.0 odoo-server - -# Create virtual environment -RUN python3 -m venv venv - -# Install Python dependencies -RUN /opt/odoo/venv/bin/pip install --upgrade pip \ - && /opt/odoo/venv/bin/pip install -r /opt/odoo/odoo-server/requirements.txt \ - && /opt/odoo/venv/bin/pip install phonenumbers - -# Create Odoo config directory in /opt/odoo (writable by odoo user) -RUN mkdir -p /opt/odoo \ - && touch /opt/odoo/odoo.conf \ - && chown odoo:odoo /opt/odoo/odoo.conf \ - && chmod 640 /opt/odoo/odoo.conf - -# Environment variables for database configuration -ENV DB_HOST=postgres -ENV DB_PORT=5432 -ENV DB_USER=odoo -ENV DB_PASSWORD=odoo -ENV ADMIN_PASSWD=my_admin_password - -# Expose Odoo ports -EXPOSE 8069 8072 - -# Volume for custom addons -VOLUME ["/opt/odoo/custom_addons"] - -# Set working directory -WORKDIR /opt/odoo/odoo-server - -# Copy entrypoint script and admin creation script -COPY odoo-entrypoint.sh /odoo-entrypoint.sh -RUN chmod +x /odoo-entrypoint.sh - -# Start Odoo -USER odoo -ENTRYPOINT ["/odoo-entrypoint.sh"] diff --git a/Services/postgres/postgres.README b/Services/postgres/postgres.README deleted file mode 100644 index 8765ec0..0000000 --- a/Services/postgres/postgres.README +++ /dev/null @@ -1,12 +0,0 @@ -# Create DB - -Create User -$ podman exec -it postgres psql -U postgres -c "CREATE USER [nome_progetto] WITH password '[password_db_progetto]';" - -Or with CREATEDB -$ podman exec -it postgres psql -U postgres -c "CREATE USER [nome_progetto] WITH password '[password_db_progetto]' CREATEDB;" - -Create DB -$ podman exec -it postgres psql -U postgres -c "CREATE DATABASE [nome_progetto];" -$ podman exec -it postgres psql -U postgres -c "GRANT ALL privileges ON DATABASE [nome_progetto] TO [nome_progetto];" -$ podman exec -it postgres psql -U postgres -d [nome_progetto] -c "GRANT CREATE ON SCHEMA public TO [nome_progetto];" diff --git a/Services/searxng.container b/Services/searxng.container deleted file mode 100644 index 98420ba..0000000 --- a/Services/searxng.container +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Name=searxng - -[Container] -ContainerName=searxng -Image=docker.io/searxng/searxng:latest -#AutoUpdate=registry -Network=internal.network -#PublishPort=8888:8080 - -# Production -Volume=/srv/containers/aitools/searxng/config:/etc/searxng -Volume=/srv/containers/aitools/searxng/data:/var/cache/searxng - -[Service] -TimeoutStartSec=5m -Restart=on-failure - -[Install] -WantedBy=multi-user.target default.target \ No newline at end of file diff --git a/Services/gitea/app.ini b/containers/gitea/app.ini similarity index 100% rename from Services/gitea/app.ini rename to containers/gitea/app.ini diff --git a/Services/gitea/gitea.container b/containers/gitea/gitea.container similarity index 83% rename from Services/gitea/gitea.container rename to containers/gitea/gitea.container index 8f2056f..97faa16 100644 --- a/Services/gitea/gitea.container +++ b/containers/gitea/gitea.container @@ -8,7 +8,6 @@ Wants=network-online.target ContainerName=gitea Image=docker.gitea.com/gitea:latest #AutoUpdate=registry -UserNS=keep-id Network=internal.network #NetworkAlias=gitea @@ -16,11 +15,6 @@ Network=internal.network PublishPort=3000:3000 PublishPort=2222:22 -User=0:0 -UserNS=keep-id -#Environment=USER_UID=1002 -#Environment=USER_GID=1002 - Volume=/srv/containers/gitea/data:/data Volume=/srv/containers/gitea/config:/data/gitea/conf diff --git a/Services/gitea/gitea.nginx b/containers/gitea/gitea.nginx similarity index 100% rename from Services/gitea/gitea.nginx rename to containers/gitea/gitea.nginx diff --git a/Services/llamacpp/llamacpp-embedding.container b/containers/llamacpp/llamacpp-embedding.container similarity index 100% rename from Services/llamacpp/llamacpp-embedding.container rename to containers/llamacpp/llamacpp-embedding.container diff --git a/Services/llamacpp/llamacpp-mistral.Containerfile b/containers/llamacpp/llamacpp-mistral.Containerfile similarity index 100% rename from Services/llamacpp/llamacpp-mistral.Containerfile rename to containers/llamacpp/llamacpp-mistral.Containerfile diff --git a/Services/llamacpp/llamacpp-vulkan.Containerfile b/containers/llamacpp/llamacpp-vulkan.Containerfile similarity index 100% rename from Services/llamacpp/llamacpp-vulkan.Containerfile rename to containers/llamacpp/llamacpp-vulkan.Containerfile diff --git a/Services/llamacpp/llamacpp.README b/containers/llamacpp/llamacpp.README similarity index 100% rename from Services/llamacpp/llamacpp.README rename to containers/llamacpp/llamacpp.README diff --git a/Services/llamacpp/llamacpp.container b/containers/llamacpp/llamacpp.container similarity index 100% rename from Services/llamacpp/llamacpp.container rename to containers/llamacpp/llamacpp.container diff --git a/Services/llamacpp/llamacpp.nginx b/containers/llamacpp/llamacpp.nginx similarity index 100% rename from Services/llamacpp/llamacpp.nginx rename to containers/llamacpp/llamacpp.nginx diff --git a/containers/mattermost/mattermost.container b/containers/mattermost/mattermost.container new file mode 100644 index 0000000..b26ddd5 --- /dev/null +++ b/containers/mattermost/mattermost.container @@ -0,0 +1,46 @@ +[Unit] +Name=mattermost +After=network-online.target +After=postgres.service +Wants=network-online.target + +[Container] +ContainerName=mattermost +Image=mattermost/mattermost-team-edition:latest +#AutoUpdate=registry + +Network=internal.network +#NetworkAlias=mattermost + +PublishPort=8065:8065 + +# Database Configuration +Environment=MM_SQLSETTINGS_DRIVERNAME=postgres +Environment=MM_SQLSETTINGS_DATASOURCE=postgres://mattermost:mattermost@postgres:5432/mattermost?sslmode=disable + +# Mattermost Settings +Environment=MM_SERVICESETTINGS_SITEURL=https://mattermost.example.com +Environment=MM_SERVICESETTINGS_LISTENADDRESS=:8065 + +# File Storage +Environment=MM_FILESETTINGS_DRIVERNAME=local +Environment=MM_FILESETTINGS_DIRECTORY=/mattermost/data/files + +# Logging +Environment=MM_LOGSETTINGS_ENABLEFILE=true +Environment=MM_LOGSETTINGS_FILELEVEL=info + +# mkdir -p /srv/containers/mattermost/{config,data,logs,plugins,client-plugins,bleve-indexes} +Volume=/srv/containers/mattermost/config:/mattermost/config +Volume=/srv/containers/mattermost/data:/mattermost/data +Volume=/srv/containers/mattermost/logs:/mattermost/logs +Volume=/srv/containers/mattermost/plugins:/mattermost/plugins +Volume=/srv/containers/mattermost/client-plugins:/mattermost/client/plugins +Volume=/srv/containers/mattermost/bleve-indexes:/mattermost/bleve-indexes + +[Service] +TimeoutStartSec=5m +Restart=always + +[Install] +WantedBy=multi-user.target default.target diff --git a/containers/mattermost/mattermost.nginx b/containers/mattermost/mattermost.nginx new file mode 100644 index 0000000..2a8241b --- /dev/null +++ b/containers/mattermost/mattermost.nginx @@ -0,0 +1,50 @@ +server { + listen 80; + listen [::]:80; + server_name mattermost.example.com; + + # Redirect HTTP to HTTPS + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name mattermost.example.com; + + # SSL Configuration + ssl_certificate /etc/letsencrypt/live/mattermost.example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/mattermost.example.com/privkey.pem; + + # SSL Settings + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + + # Proxy Settings + client_max_body_size 50M; + + # Mattermost upstream + location / { + proxy_pass http://mattermost:8065; + proxy_http_version 1.1; + proxy_buffering off; + + # Headers + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Forwarded-Port $server_port; + + # WebSocket support + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + # Timeouts + proxy_connect_timeout 7d; + proxy_send_timeout 7d; + proxy_read_timeout 7d; + } +} diff --git a/containers/n8n/n8n.container b/containers/n8n/n8n.container new file mode 100644 index 0000000..471213c --- /dev/null +++ b/containers/n8n/n8n.container @@ -0,0 +1,32 @@ +[Unit] +Name=n8n + +[Container] +Image=docker.n8n.io/n8nio/n8n +ContainerName=n8n +Network=internal.network + +#PublishPort=5678:5678 + +Environment=GENERIC_TIMEZONE=Europe/Rome +Environment=TZ=Europe/Rome +Environment=N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true +Environment=N8N_RUNNERS_ENABLED=true +Environment=N8N_EDITOR_BASE_URL=https://workflow.internal.ai.duckpage.net +Environment=DB_TYPE=postgresdb +Environment=DB_POSTGRESDB_DATABASE=n8n +Environment=DB_POSTGRESDB_HOST=postgres +Environment=DB_POSTGRESDB_PORT=5432 +Environment=DB_POSTGRESDB_USER=n8n +Environment=DB_POSTGRESDB_SCHEMA=public +Environment=DB_POSTGRESDB_PASSWORD=M7eRzI2TsM9M92Bx + +# Production +Volume=/srv/containers/n8n:/home/node/.n8n + +[Service] +TimeoutStartSec=5m +Restart=on-failure + +[Install] +WantedBy=multi-user.target default.target \ No newline at end of file diff --git a/containers/navidrome/navidrome.container b/containers/navidrome/navidrome.container new file mode 100644 index 0000000..8c3c2de --- /dev/null +++ b/containers/navidrome/navidrome.container @@ -0,0 +1,26 @@ +[Unit] +Name=navidrome +After=network-online.target +Wants=network-online.target + +[Container] +ContainerName=navidrome +Image=deluan/navidrome:latest +#AutoUpdate=registry + +Network=internal.network +#NetworkAlias=navidrome + +PublishPort=4533:4533 + +Environment=ND_LOGLEVEL=info + +Volume=/srv/containers/navidrome/music:/music +Volume=/srv/containers/navidrome/data:/data + +[Service] +TimeoutStartSec=5m +Restart=always + +[Install] +WantedBy=multi-user.target default.target diff --git a/Services/nextcloud/collaboraoffice.container b/containers/nextcloud/collaboraoffice.container similarity index 100% rename from Services/nextcloud/collaboraoffice.container rename to containers/nextcloud/collaboraoffice.container diff --git a/Services/nextcloud/collaboraoffice.nginx b/containers/nextcloud/collaboraoffice.nginx similarity index 100% rename from Services/nextcloud/collaboraoffice.nginx rename to containers/nextcloud/collaboraoffice.nginx diff --git a/Services/nextcloud/nextcloud-push.container b/containers/nextcloud/nextcloud-push.container similarity index 100% rename from Services/nextcloud/nextcloud-push.container rename to containers/nextcloud/nextcloud-push.container diff --git a/Services/nextcloud/nextcloud.README b/containers/nextcloud/nextcloud.README similarity index 100% rename from Services/nextcloud/nextcloud.README rename to containers/nextcloud/nextcloud.README diff --git a/Services/nextcloud/nextcloud.container b/containers/nextcloud/nextcloud.container similarity index 100% rename from Services/nextcloud/nextcloud.container rename to containers/nextcloud/nextcloud.container diff --git a/Services/nextcloud/nextcloud.nginx b/containers/nextcloud/nextcloud.nginx similarity index 100% rename from Services/nextcloud/nextcloud.nginx rename to containers/nextcloud/nextcloud.nginx diff --git a/Services/nextcloud/redis.container b/containers/nextcloud/redis.container similarity index 100% rename from Services/nextcloud/redis.container rename to containers/nextcloud/redis.container diff --git a/Services/nginx/certbot.README b/containers/nginx/certbot.README similarity index 100% rename from Services/nginx/certbot.README rename to containers/nginx/certbot.README diff --git a/Services/nginx/nginx.container b/containers/nginx/nginx.container similarity index 100% rename from Services/nginx/nginx.container rename to containers/nginx/nginx.container diff --git a/Services/nginx/selfssl.README b/containers/nginx/selfssl.README similarity index 100% rename from Services/nginx/selfssl.README rename to containers/nginx/selfssl.README diff --git a/containers/odoo/build-container.sh b/containers/odoo/build-container.sh new file mode 100755 index 0000000..aee8dca --- /dev/null +++ b/containers/odoo/build-container.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Build dell'immagine Odoo a partire dal pacchetto .deb ufficiale (community/enterprise) +# I file .deb vanno messi in ./deb (tracciati con git-lfs, vedi .gitattributes) +# Usage: ./build-container.sh [community|enterprise] [--no-cache] + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +DEB_DIR="${SCRIPT_DIR}/deb" + +EDITION="" +NO_CACHE="" +USE_CACHE=false + +for arg in "$@"; do + case "$arg" in + --no-cache) NO_CACHE="--no-cache" ;; + --use-cache) USE_CACHE=true ;; + community|enterprise) EDITION="$arg" ;; + esac +done + +# Se non specificata da riga di comando, chiedi la versione +if [[ "$EDITION" != "community" && "$EDITION" != "enterprise" ]]; then + echo "Quale versione di Odoo vuoi buildare?" + select choice in "community" "enterprise"; do + case "$choice" in + community|enterprise) + EDITION="$choice" + break + ;; + *) + echo "Scelta non valida, riprova." + ;; + esac + done +fi + +# Default: forza --no-cache per evitare di usare cache con ARG vecchio +# (a meno che non venga passato --use-cache) +if [[ "$USE_CACHE" == "false" ]]; then + NO_CACHE="--no-cache" +fi + +case "$EDITION" in + community) DEB_FILE="odoo_19_c.deb" ;; + enterprise) DEB_FILE="odoo_19_e.deb" ;; +esac + +if [ ! -f "${DEB_DIR}/${DEB_FILE}" ]; then + echo "ERRORE: ${DEB_DIR}/${DEB_FILE} non trovato." + echo "Copia il pacchetto .deb ufficiale di Odoo in ${DEB_DIR} (gestito tramite git-lfs, vedi .gitattributes)." + exit 1 +fi + +IMAGE_TAG="odoo:19.0-${EDITION}" + +echo "=== Build immagine Odoo (${EDITION}) ===" +echo "Pacchetto: ${DEB_FILE}" +echo "Image tag: localhost/${IMAGE_TAG}" +echo + +# Debug: verifica che la variabile è corretta +echo "[DEBUG] DEB_FILE=${DEB_FILE}" +echo "[DEBUG] Comando: podman build --build-arg ODOO_DEB_FILE=${DEB_FILE} ..." +echo + +podman build $NO_CACHE \ + --build-arg "ODOO_DEB_FILE=${DEB_FILE}" \ + -t "${IMAGE_TAG}" \ + -f "${SCRIPT_DIR}/odoo.Containerfile" \ + "${SCRIPT_DIR}" + +echo +echo "✓ Immagine creata: localhost/${IMAGE_TAG}" +echo +echo "Per esportarla:" +echo " podman save -o ~/odoo-19.0-${EDITION}.tar localhost/${IMAGE_TAG}" diff --git a/containers/odoo/deb/odoo_19_c.deb b/containers/odoo/deb/odoo_19_c.deb new file mode 100644 index 0000000..d6d45e8 --- /dev/null +++ b/containers/odoo/deb/odoo_19_c.deb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab5bae04dd98b7710a3e4c3ab5a8fc373feefb32747f4ddf343b440468a5265d +size 228938904 diff --git a/Services/odoo/odoo-entrypoint.sh b/containers/odoo/odoo-entrypoint.sh similarity index 55% rename from Services/odoo/odoo-entrypoint.sh rename to containers/odoo/odoo-entrypoint.sh index b49643c..4d979e7 100644 --- a/Services/odoo/odoo-entrypoint.sh +++ b/containers/odoo/odoo-entrypoint.sh @@ -8,12 +8,12 @@ DB_PORT="${DB_PORT:-5432}" DB_USER="${DB_USER:-odoo}" DB_PASSWORD="${DB_PASSWORD:-odoo}" DB_NAME="${DB_NAME:-}" +DB_TEMPLATE="${DB_TEMPLATE:-template1}" -# Crea la directory di configurazione in /opt/odoo -mkdir -p /opt/odoo +CONFIG_FILE=/etc/odoo/odoo.conf # Crea il file di configurazione Odoo con i valori delle variabili d'ambiente -cat > /opt/odoo/odoo.conf << EOF +cat > "$CONFIG_FILE" << EOF [options] ; Server Configuration admin_passwd = $ADMIN_PASSWD @@ -21,28 +21,27 @@ db_host = $DB_HOST db_port = $DB_PORT db_user = $DB_USER db_password = $DB_PASSWORD +db_template = $DB_TEMPLATE EOF # Aggiungi db_name e list_db a seconda se DB_NAME è impostata if [ -n "$DB_NAME" ]; then - cat >> /opt/odoo/odoo.conf << EOF + cat >> "$CONFIG_FILE" << EOF db_name = $DB_NAME list_db = False EOF else - cat >> /opt/odoo/odoo.conf << EOF -list_db = True -EOF + echo "list_db = True" >> "$CONFIG_FILE" fi -cat >> /opt/odoo/odoo.conf << EOF +cat >> "$CONFIG_FILE" << EOF -; File Paths -addons_path = /opt/odoo/odoo-server/addons,/opt/odoo/custom_addons -data_dir = /opt/odoo/data +; File Paths (installazione tramite pacchetto .deb ufficiale) +addons_path = /usr/lib/python3/dist-packages/odoo/addons,/var/lib/odoo/custom_addons +data_dir = /var/lib/odoo/.local/share/Odoo ; Logging -log_file = /opt/odoo/odoo.log +logfile = /var/log/odoo/odoo.log log_level = info ; Workers (optional, for production) @@ -53,32 +52,26 @@ gevent_port = 8072 max_cron_threads = 2 EOF -# Attiva il virtual environment -source /opt/odoo/venv/bin/activate - -# Vai nella directory di Odoo -cd /opt/odoo/odoo-server - # Inizializza il database solo se DB_NAME è impostato e il file .odoo_initialized non esiste -if [ -n "$DB_NAME" ] && [ ! -f /opt/odoo/.odoo_initialized ]; then +if [ -n "$DB_NAME" ] && [ ! -f /var/lib/odoo/.odoo_initialized ]; then echo "Inizializzazione del database..." - + # Verifica e crea il database se necessario - DB_EXISTS=$(PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -U $DB_USER -lqt 2>/dev/null | cut -d'|' -f1 | grep -w $DB_NAME | wc -l) - + DB_EXISTS=$(PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -lqt 2>/dev/null | cut -d'|' -f1 | grep -w $DB_NAME | wc -l) + if [ "$DB_EXISTS" -eq 0 ]; then echo "Creazione del database $DB_NAME..." - PGPASSWORD=$DB_PASSWORD createdb -h $DB_HOST -U $DB_USER $DB_NAME + PGPASSWORD=$DB_PASSWORD createdb -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME fi - + # Inizializza il database - ./odoo-bin -c /opt/odoo/odoo.conf -i base --stop-after-init --without-demo - + /usr/bin/odoo -c "$CONFIG_FILE" -i base --stop-after-init --without-demo=True + # Crea il file di flag per indicare che l'inizializzazione è completata - touch /opt/odoo/.odoo_initialized - + touch /var/lib/odoo/.odoo_initialized + echo "Database inizializzato." fi # Avvia Odoo -exec ./odoo-bin -c /opt/odoo/odoo.conf +exec /usr/bin/odoo -c "$CONFIG_FILE" diff --git a/containers/odoo/odoo.Containerfile b/containers/odoo/odoo.Containerfile new file mode 100644 index 0000000..089a980 --- /dev/null +++ b/containers/odoo/odoo.Containerfile @@ -0,0 +1,68 @@ +# syntax=docker/dockerfile:1.9 +# Build: use ./build-container.sh (chiede community/enterprise e passa ODOO_DEB_FILE) +# Manuale: podman build --build-arg ODOO_DEB_FILE=odoo_19_c.deb -t odoo:19.0-community -f odoo.Containerfile . +# +# Installa Odoo dal pacchetto .deb ufficiale (community o enterprise), i pacchetti +# ufficiali Odoo 19 sono compilati per Ubuntu Noble: da qui la base ubuntu:24.04. + +FROM ubuntu:24.04 + +# Nome del file .deb (in deb/) da installare, scelto da build-container.sh +ARG ODOO_DEB_FILE=odoo_19_c.deb + +ENV DEBIAN_FRONTEND=noninteractive + +# Durante il build non è attivo alcun init system: impediamo allo script +# postinst del pacchetto di provare ad avviare il servizio odoo. +RUN printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d \ + && chmod +x /usr/sbin/policy-rc.d + +# Il repository "universe" fornisce molte delle dipendenze python3-* di Odoo +RUN apt-get update \ + && apt-get install -y --no-install-recommends software-properties-common \ + && add-apt-repository -y universe \ + && rm -rf /var/lib/apt/lists/* + +# wkhtmltopdf (build Qt patchata) non è incluso nel pacchetto Odoo +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + fontconfig \ + libxrender1 \ + libxext6 \ + xfonts-75dpi \ + xfonts-base \ + && curl -sSL -o /tmp/wkhtmltox.deb "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.jammy_amd64.deb" \ + && apt-get install -y /tmp/wkhtmltox.deb \ + && rm -rf /var/lib/apt/lists/* /tmp/wkhtmltox.deb + +# Installazione di Odoo dal pacchetto .deb ufficiale (crea utente/gruppo odoo, +# /etc/odoo/odoo.conf, /var/lib/odoo, /var/log/odoo e risolve le dipendenze via apt). +# --no-install-recommends evita di installare un server PostgreSQL locale +# (il pacchetto lo raccomanda, ma il DB gira in un container separato). +RUN echo "=== COPIANDO: deb/${ODOO_DEB_FILE} ===" + +COPY deb/${ODOO_DEB_FILE} /tmp/odoo.deb +RUN apt-get update \ + && apt-get install -y --no-install-recommends /tmp/odoo.deb \ + && rm -rf /var/lib/apt/lists/* /tmp/odoo.deb + +# Directory per gli addons custom (montata come volume) +RUN mkdir -p /var/lib/odoo/custom_addons \ + && mkdir -p /var/lib/odoo/.local/share/Odoo/sessions \ + && mkdir -p /var/lib/odoo/.local/share/Odoo/filestore \ + && chown -R odoo:odoo /var/lib/odoo \ + && chmod -R 755 /var/lib/odoo/.local \ + && chmod 700 /var/lib/odoo/custom_addons \ + && chmod 700 /var/lib/odoo/.local/share/Odoo/sessions \ + && chmod 700 /var/lib/odoo/.local/share/Odoo/filestore + +EXPOSE 8069 8072 + +VOLUME ["/var/lib/odoo/custom_addons"] + +COPY odoo-entrypoint.sh /odoo-entrypoint.sh +RUN chmod +x /odoo-entrypoint.sh + +USER odoo +ENTRYPOINT ["/odoo-entrypoint.sh"] diff --git a/Services/odoo/odoo.container b/containers/odoo/odoo.container similarity index 67% rename from Services/odoo/odoo.container rename to containers/odoo/odoo.container index 7d821e8..9889dbc 100644 --- a/Services/odoo/odoo.container +++ b/containers/odoo/odoo.container @@ -1,22 +1,22 @@ [Container] ContainerName=odoo -Image=localhost/odoo:19-amd64 +Image=localhost/odoo:19.0-community #AutoUpdate=registry Network=internal.network PublishPort=8069:8069 PublishPort=8072:8072 # Custom addons volume -Volume=/srv/containers/odoo/custom_addons:/opt/odoo/custom_addons -Volume=/srv/containers/odoo/filestore:/opt/odoo/data/filestore +Volume=/srv/containers/odoo/custom_addons:/var/lib/odoo/custom_addons +Volume=/srv/containers/odoo/filestore:/var/lib/odoo/.local/share/Odoo/filestore # Database connection (adjust host if needed) -Environment=ADMIN_PASSWD=my_admin_password Environment=DB_HOST=postgres Environment=DB_PORT=5432 Environment=DB_USER=odoo Environment=DB_PASSWORD=odoo -#Environment=DB_NAME=mydb +Environment=DB_TEMPLATE=template1 +Environment=ADMIN_PASSWD=my_admin_password [Service] diff --git a/containers/postgres/postgres-vector.container b/containers/postgres/postgres-vector.container new file mode 100644 index 0000000..2bfdc4b --- /dev/null +++ b/containers/postgres/postgres-vector.container @@ -0,0 +1,21 @@ +[Unit] +Name=postgres + +[Container] +ContainerName=postgres +Image=pgvector/pgvector:pg18-trixie +#AutoUpdate=registry +Network=internal.network +Environment=POSTGRES_USER=postgres +Environment=POSTGRES_PASSWORD=postgres +#PublishPort=5432:5432 + +Volume=/srv/containers/postgres:/var/lib/postgresql + + +[Service] +TimeoutStartSec=5m +Restart=on-failure + +[Install] +WantedBy=multi-user.target default.target diff --git a/containers/postgres/postgres.README b/containers/postgres/postgres.README new file mode 100644 index 0000000..15e2315 --- /dev/null +++ b/containers/postgres/postgres.README @@ -0,0 +1,29 @@ +## Solo per postgres-vector + +### Setup iniziale (eseguire una volta) +Abilita pgvector su `template1` così tutti i nuovi database lo avranno automaticamente: + +```bash +podman exec -it postgres psql -U postgres -d template1 -c "CREATE EXTENSION IF NOT EXISTS vector;" +``` +---- + +# Create DB + +Create User +```bash +podman exec -it postgres psql -U postgres -c "CREATE USER [nome_progetto] WITH password '[password_db_progetto]';" +``` + +Or with CREATEDB +```bash +podman exec -it postgres psql -U postgres -c "CREATE USER [nome_progetto] WITH password '[password_db_progetto]' CREATEDB;" +``` + +Create DB +```bash +podman exec -it postgres psql -U postgres -c "CREATE DATABASE [nome_progetto];" +podman exec -it postgres psql -U postgres -c "GRANT ALL privileges ON DATABASE [nome_progetto] TO [nome_progetto];" +podman exec -it postgres psql -U postgres -d [nome_progetto] -c "GRANT CREATE ON SCHEMA public TO [nome_progetto];" +``` + diff --git a/Services/postgres/postgres.container b/containers/postgres/postgres.container similarity index 100% rename from Services/postgres/postgres.container rename to containers/postgres/postgres.container diff --git a/containers/qwentts/build-container.sh b/containers/qwentts/build-container.sh new file mode 100644 index 0000000..ac08068 --- /dev/null +++ b/containers/qwentts/build-container.sh @@ -0,0 +1,83 @@ +#!/bin/bash +set -e + +BUILD_DIR="$(pwd)/qwentts-src" +BIN_DIR="$(pwd)/bin-vulkan" + +echo "=== Qwentts.cpp Build Script for Vulkan ===" +echo "" + +# Step 1: Install dependencies +echo "[1/5] Installing build dependencies..." +sudo apt-get update +sudo apt-get install -y \ + build-essential \ + cmake \ + git \ + libvulkan-dev \ + vulkan-tools \ + glslc \ + spirv-tools \ + pkg-config + +# Step 2: Clone qwentts.cpp with submodules +echo "" +echo "[2/5] Cloning qwentts.cpp repository with submodules..." +if [ -d "$BUILD_DIR" ]; then + rm -rf "$BUILD_DIR" +fi +git clone --recurse-submodules https://github.com/ServeurpersoCom/qwentts.cpp "$BUILD_DIR" +cd "$BUILD_DIR" + +# Step 3: Build with Vulkan backend +echo "" +echo "[3/5] Building qwentts with Vulkan support..." +./buildvulkan.sh + +# Step 4: Copy binaries to bin-vulkan/ +echo "" +echo "[4/5] Copying binaries to bin-vulkan/..." +if [ -d "$BIN_DIR" ]; then + rm -rf "$BIN_DIR" +fi +mkdir -p "$BIN_DIR" + +# Copy executables +cp build/qwen-tts "$BIN_DIR/" +cp build/qwen-codec "$BIN_DIR/" + +# Copy any shared libraries if they exist +if [ -d "build/lib" ]; then + cp -r build/lib "$BIN_DIR/" +fi + +# Step 5: Create entrypoint script +echo "" +echo "[5/5] Creating entrypoint script..." +cat > "$(pwd)/../entrypoint.sh" <<'ENTRYPOINT_EOF' +#!/bin/bash +set -e + +# Export Vulkan driver path +export VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.x86_64.json +export LD_LIBRARY_PATH=/app/lib:$LD_LIBRARY_PATH + +# Default to help if no arguments +if [ $# -eq 0 ]; then + /app/bin/qwen-tts --help +else + exec "$@" +fi +ENTRYPOINT_EOF + +chmod +x "$(pwd)/../entrypoint.sh" + +echo "" +echo "=== Build Complete ===" +echo "Binaries are in: $BIN_DIR" +echo "Models should be placed in: $(pwd)/../models/" +echo "" +echo "Next steps:" +echo "1. Download models: https://huggingface.co/Serveurperso/Qwen3-TTS-GGUF" +echo "2. Build Podman image: podman build -t qwentts:vulkan-amd64 -f qwentts-vulkan.Containerfile ." +echo "3. Test: podman run --rm qwentts:vulkan-amd64" diff --git a/containers/qwentts/qwentts-vulkan.Containerfile b/containers/qwentts/qwentts-vulkan.Containerfile new file mode 100644 index 0000000..40e23df --- /dev/null +++ b/containers/qwentts/qwentts-vulkan.Containerfile @@ -0,0 +1,31 @@ +FROM debian:13-slim + +# Install Vulkan runtime libraries +RUN apt-get update && apt-get install -y \ + libvulkan1 \ + vulkan-tools \ + mesa-vulkan-drivers \ + libdrm-amdgpu1 \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Create app directory +WORKDIR /app + +# Copy pre-compiled binaries and models +COPY bin-vulkan/ /app/bin/ +COPY entrypoint.sh /app/ + +# Create directories for models and output +RUN mkdir -p /app/models /app/output + +# Set library path for Vulkan +ENV LD_LIBRARY_PATH=/app/lib:$LD_LIBRARY_PATH +ENV VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.x86_64.json + +# Expose port for API server (if used) +EXPOSE 8080 + +# Default command +ENTRYPOINT ["/app/entrypoint.sh"] +CMD ["--help"] diff --git a/containers/qwentts/qwentts.README b/containers/qwentts/qwentts.README new file mode 100644 index 0000000..5f47c8d --- /dev/null +++ b/containers/qwentts/qwentts.README @@ -0,0 +1,343 @@ +# Qwentts - Text-to-Speech with Voice Cloning and Voice Design + +C++17 port di Qwen3-TTS (Alibaba/Qwen team) con supporto per Text-to-Speech, voice cloning zero-shot e voice design. Supporta 10+ lingue con dialetti Mandarin e output 24 kHz mono. + +## Requisiti + +- Podman rootless +- Network `internal.network` configurata +- Nginx come reverse proxy +- GPU AMD con Vulkan (opzionale, consigliato) +- Spazio disco: almeno 30 GB per i modelli +- RAM: 16+ GB per il modello 1.7B +- Dipendenze di compilazione (cmake, git, gcc, vulkan-dev) + +## Build Container + +### 1. Compilare qwentts.cpp + +```bash +cd /home/badstorm/Source/bdi/bdi_podman_serverconf/containers/qwentts +./build-container.sh +``` + +Lo script: +- Installa dipendenze (cmake, git, vulkan-dev, glslc, spirv-tools) +- Clona qwentts.cpp con submoduli ricorsivi +- Compila con `./buildvulkan.sh` per supporto Vulkan +- Copia i binari (`qwen-tts`, `qwen-codec`) in `bin-vulkan/` +- Crea l'entrypoint script + +### 2. Buildare l'immagine Podman + +```bash +podman build -t qwentts:vulkan-amd64 -f qwentts-vulkan.Containerfile . +``` + +### 3. Verificare l'immagine + +```bash +podman images | grep qwentts +podman run --rm qwentts:vulkan-amd64 --help +``` + +## Setup Runtime + +### 1. Creare le directory di dati + +```bash +mkdir -p /srv/containers/qwentts/models +mkdir -p /srv/containers/qwentts/output +chmod 755 /srv/containers/qwentts +chmod 755 /srv/containers/qwentts/models +chmod 755 /srv/containers/qwentts/output +``` + +### 2. Scaricare i modelli + +I modelli pre-convertiti sono disponibili su Hugging Face: https://huggingface.co/Serveurperso/Qwen3-TTS-GGUF + +Scarica almeno un modello talker e il tokenizer: + +```bash +cd /srv/containers/qwentts/models +pip install huggingface-hub + +# Download Base Model (1.7B, default voice) +huggingface-cli download Serveurperso/Qwen3-TTS-GGUF \ + qwen-talker-1.7b-base-Q8_0.gguf \ + qwen-tokenizer-12hz-Q8_0.gguf \ + --local-dir . + +# Optional: Download CustomVoice Model (named speakers) +huggingface-cli download Serveurperso/Qwen3-TTS-GGUF \ + qwen-talker-1.7b-customvoice-Q8_0.gguf \ + --local-dir . + +# Optional: Download VoiceDesign Model (voice attributes) +huggingface-cli download Serveurperso/Qwen3-TTS-GGUF \ + qwen-talker-1.7b-voicedesign-Q8_0.gguf \ + --local-dir . + +# Optional: Smaller 0.6B models for faster inference +huggingface-cli download Serveurperso/Qwen3-TTS-GGUF \ + qwen-talker-0.6b-base-Q8_0.gguf \ + --local-dir . +``` + +**Opzioni di quantizzazione disponibili:** +- `Q8_0` - Nessuna perdita di qualità, ~50% riduzione dimensione +- `Q4_K_M` - Quantizzazione mista, miglior rapporto qualità/dimensione +- `F32` - Massima qualità, dimensione massima + +### 3. Copiare il file quadlet + +```bash +cp qwentts.container ~/.config/containers/systemd/ +``` + +### 4. Configurare il dominio + +Modifica il file `~/.config/containers/systemd/qwentts.container` se necessario: +- Volumi di modelli e output +- Limiti di memoria (attualmente 16GB) +- Limiti CPU + +### 5. Copiare la configurazione Nginx + +```bash +cp qwentts.nginx /etc/nginx/conf.d/qwentts.conf +``` + +Modifica il file per sostituire: +- `qwentts.example.com` con il tuo dominio reale +- Percorsi SSL (standard Let's Encrypt) + +### 6. Configurare SSL + +```bash +sudo certbot certonly --standalone -d qwentts.tuodominio.com +``` + +### 7. Riavviare Nginx + +```bash +sudo systemctl reload nginx +# oppure per container nginx: +systemctl --user restart nginx +``` + +### 8. Avviare Qwentts + +```bash +systemctl --user daemon-reload +systemctl --user start qwentts +systemctl --user enable qwentts +``` + +## Verifica + +Controlla che il container sia in esecuzione: + +```bash +podman ps | grep qwentts +podman logs qwentts +``` + +## Utilizzo CLI + +Qwentts fornisce due tool CLI: `qwen-tts` per la sintesi e `qwen-codec` per la gestione codec. + +### Text-to-Speech Base (voce predefinita) + +```bash +echo "Hello, this is a test." | podman exec qwentts qwen-tts \ + --model /app/models/qwen-talker-1.7b-base-Q8_0.gguf \ + --codec /app/models/qwen-tokenizer-12hz-Q8_0.gguf \ + --lang English \ + -o /app/output/test.wav +``` + +### Voice Cloning (Zero-Shot) + +**Opzione 1: Usa WAV + Testo di riferimento** + +```bash +echo "I am cloning this voice." | podman exec qwentts qwen-tts \ + --model /app/models/qwen-talker-1.7b-base-Q8_0.gguf \ + --codec /app/models/qwen-tokenizer-12hz-Q8_0.gguf \ + --ref-wav /app/output/reference.wav \ + --ref-text "This is my reference voice sample" \ + --lang English \ + -o /app/output/cloned.wav +``` + +**Opzione 2: Pre-encode il riferimento (più efficiente)** + +```bash +# Estrai speaker embedding e codici +podman exec qwentts qwen-codec \ + --model /app/models/qwen-tokenizer-12hz-Q8_0.gguf \ + --talker /app/models/qwen-talker-1.7b-base-Q8_0.gguf \ + -i /app/output/reference.wav + +# Sintetizza usando i file pre-encodati +echo "Now I can synthesize with this voice." | podman exec qwentts qwen-tts \ + --model /app/models/qwen-talker-1.7b-base-Q8_0.gguf \ + --codec /app/models/qwen-tokenizer-12hz-Q8_0.gguf \ + --ref-spk /app/output/reference.spk \ + --ref-rvq /app/output/reference.rvq \ + --ref-text "This is my reference voice sample" \ + --lang English \ + -o /app/output/synthesized.wav +``` + +### Named Speakers (CustomVoice Mode) + +Voci predefinite disponibili: serena, vivian, uncle_fu, ryan, aiden, ono_anna, sohee, eric (dialetto sichuan), dylan (dialetto beijing) + +```bash +echo "Hello from a named speaker." | podman exec qwentts qwen-tts \ + --model /app/models/qwen-talker-1.7b-customvoice-Q8_0.gguf \ + --codec /app/models/qwen-tokenizer-12hz-Q8_0.gguf \ + --speaker vivian \ + --lang English \ + -o /app/output/vivian.wav +``` + +### Voice Design (Attributi di Voce) + +Descrivi gli attributi della voce desiderata in testo libero: + +```bash +echo "A very friendly and warm conversation starter." | podman exec qwentts qwen-tts \ + --model /app/models/qwen-talker-1.7b-voicedesign-Q8_0.gguf \ + --codec /app/models/qwen-tokenizer-12hz-Q8_0.gguf \ + --instruct "female, young adult, cheerful, moderate pitch" \ + --lang English \ + -o /app/output/designed.wav +``` + +Esempi di descrizioni: +- "male, professional, deep voice, authoritative" +- "female, elderly, warm and nurturing" +- "non-binary, young, energetic and upbeat" +- "child, playful, high-pitched, innocent" + +## Lingue Supportate + +- English +- Mandarin (Standard) +- Mandarin Sichuan (eric speaker) +- Mandarin Beijing (dylan speaker) +- Cantonese +- Japanese +- Korean +- Spanish +- French +- German +- Russian +- And more... + +Specifica con il flag `--lang` + +## Modelli Disponibili + +### Base Mode (Voce predefinita) +- **Size**: 1.7B o 0.6B +- **Quantization**: Q8_0, Q4_K_M, F32 +- **Caratteristiche**: Voce singola fissa, voice cloning +- **Use case**: Sintesi rapida con voice cloning da riferimento + +### CustomVoice Mode (Altoparlanti nominati) +- **Speakers**: 8 voci predefinite con nomi e dialetti +- **Size**: 1.7B +- **Caratteristiche**: Scelta rapida tra voci note +- **Use case**: Produzione di contenuto con voci consistenti + +### VoiceDesign Mode (Attributi di voce) +- **Size**: 1.7B +- **Caratteristiche**: Sintesi controllata via attributi in testo libero +- **Use case**: Creazione di voci custom con prompt descrittivi + +### Dimensioni Modelli + +| Modello | Dimensione (F32) | Q8_0 | Q4_K_M | RTF (GPU) | +|---------|-----------------|------|--------|-----------| +| 0.6B | 2.4 GB | 1.2 GB | 0.6 GB | < 0.5x | +| 1.7B | 6.8 GB | 3.4 GB | 1.7 GB | < 1.0x | + +RTF = Real-Time Factor (< 1.0 significa più veloce del tempo reale) + +## Performance + +### Benchmark (Estimated) + +**CPU (AMD Ryzen 9950X3D):** +- Sintesi 10 secondi: ~2-5 secondi + +**GPU (NVIDIA A100 o AMD GPU equivalente con Vulkan):** +- Sintesi 10 secondi: < 1 secondo + +### Ottimizzazione + +Per migliore performance: +1. Usa modello 0.6B per latenza bassa +2. Usa quantizzazione Q8_0 o superiore +3. Pre-encode i riferimenti con `qwen-codec --talker` per voice cloning +4. Aumenta memoria allocata nel quadlet se disponibile + +## Troubleshooting + +### Build falls con dipendenze mancanti +```bash +# Esegui con sudo +sudo ./build-container.sh +``` + +### Vulkan non disponibile su container +```bash +# Verifica driver Vulkan +podman run --rm --device=/dev/dri --device=/dev/kfd ghcr.io/library/debian:13-slim vulkaninfo +``` + +### Modelli non trovati +```bash +# Verifica volume mounting +podman exec qwentts ls -la /app/models +``` + +### Memory issues +Se il container crasha per memoria: +```bash +# Aumenta memoria nel quadlet (attualmente 16GB) +# Oppure usa quantizzazione Q4_K_M per ridurre consumo +``` + +### Sintesi lenta +- Verifica che Vulkan sia attivo +- Usa modello 0.6B +- Aumenta CPUQuota nel quadlet +- Verifica che /dev/dri e /dev/kfd siano accessibili + +## Aggiornamento + +Per aggiornare a una versione più recente di qwentts.cpp: + +```bash +# Ricompila +./build-container.sh + +# Rebuild immagine +podman build -t qwentts:vulkan-amd64 -f qwentts-vulkan.Containerfile . + +# Riavvia container +systemctl --user restart qwentts +``` + +## References + +- [Qwentts.cpp GitHub](https://github.com/ServeurpersoCom/qwentts.cpp) +- [Models on Hugging Face](https://huggingface.co/Serveurperso/Qwen3-TTS-GGUF) +- [Qwen3-TTS Documentation](https://docs.qwenlm.ai/) +- [Architecture & API Reference](https://github.com/ServeurpersoCom/qwentts.cpp/blob/master/docs/ARCHITECTURE.md) diff --git a/containers/qwentts/qwentts.container b/containers/qwentts/qwentts.container new file mode 100644 index 0000000..0a4d90d --- /dev/null +++ b/containers/qwentts/qwentts.container @@ -0,0 +1,31 @@ +[Unit] +Description=Qwentts (Text-to-Speech with Voice Cloning) +After=internal.network +Wants=internal.network + +[Container] +Image=localhost/qwentts:vulkan-amd64 +ContainerName=qwentts +Hostname=qwentts +Network=internal.network +PublishPort=127.0.0.1:8080:8080 + +Volume=/srv/containers/qwentts/models:/app/models:ro +Volume=/srv/containers/qwentts/output:/app/output:rw + +# GPU access - AMD Vulkan +Device=/dev/dri:/dev/dri:rw +Device=/dev/kfd:/dev/kfd:rw + +# Resource limits (adjust as needed) +Memory=16g +MemorySwap=24g +CPUQuota=50% + +# Restart policy +Restart=on-failure +RestartMaxAttempts=5 +RestartSec=10s + +[Install] +WantedBy=multi-user.target diff --git a/containers/qwentts/qwentts.nginx b/containers/qwentts/qwentts.nginx new file mode 100644 index 0000000..3326aca --- /dev/null +++ b/containers/qwentts/qwentts.nginx @@ -0,0 +1,49 @@ +upstream qwentts { + server qwentts:8080; +} + +server { + listen 80; + server_name qwentts.example.com; + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl http2; + server_name qwentts.example.com; + + ssl_certificate /etc/letsencrypt/live/qwentts.example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/qwentts.example.com/privkey.pem; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + + client_max_body_size 100m; + + # Logging + access_log /var/log/nginx/qwentts_access.log; + error_log /var/log/nginx/qwentts_error.log; + + location / { + proxy_pass http://qwentts; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # Timeouts for long-running synthesis requests + proxy_connect_timeout 120s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + send_timeout 300s; + + # Buffering for large audio files + proxy_buffering on; + proxy_buffer_size 64k; + proxy_buffers 8 64k; + proxy_busy_buffers_size 128k; + } +} diff --git a/containers/vibevoice/build-container.sh b/containers/vibevoice/build-container.sh new file mode 100644 index 0000000..ef6bc0e --- /dev/null +++ b/containers/vibevoice/build-container.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# Build vibevoice.cpp with Vulkan support and create container image +# This script compiles vibevoice.cpp locally and creates a Podman image +# Usage: ./build-container.sh [--no-cache] + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TMP_BUILD_DIR="${SCRIPT_DIR}/.tmp" +BUILD_DIR="${TMP_BUILD_DIR}/vibevoice" +BIN_DIR="${TMP_BUILD_DIR}/bin-vulkan" +NO_CACHE="" + +# Cleanup function - always runs on exit +cleanup() { + local exit_code=$? + if [ $exit_code -ne 0 ]; then + echo + echo "⚠ Build failed (exit code: $exit_code). Cleaning up temporary files..." + fi + rm -rf "$TMP_BUILD_DIR" "${SCRIPT_DIR}/bin-vulkan" 2>/dev/null || true + if [ $exit_code -eq 0 ]; then + echo "✓ Cleanup complete" + fi + return $exit_code +} + +# Set trap to cleanup on exit (success or failure) +trap cleanup EXIT + +# Parse arguments +if [[ "$1" == "--no-cache" ]]; then + NO_CACHE="--no-cache" + echo "Build mode: NO CACHE (clean rebuild)" +fi + +echo "=== Vibevoice.cpp Vulkan Build ===" +echo "Temporary build directory: $TMP_BUILD_DIR" +echo "Output directory: $BIN_DIR" +if [ -n "$NO_CACHE" ]; then + echo "Cache mode: DISABLED" +fi +echo + +# Create temporary build directory +mkdir -p "$TMP_BUILD_DIR" +echo + +# Install dependencies +echo "[1/5] Installing dependencies..." +REQUIRED_PACKAGES="build-essential cmake git libvulkan-dev vulkan-tools glslc spirv-headers spirv-tools python3" +MISSING_PACKAGES="" + +for pkg in $REQUIRED_PACKAGES; do + if ! dpkg -l | grep -q "^ii $pkg"; then + MISSING_PACKAGES="$MISSING_PACKAGES $pkg" + fi +done + +if [ -n "$MISSING_PACKAGES" ]; then + echo " Installing missing packages:$MISSING_PACKAGES" + sudo apt-get update + sudo apt-get install -y $MISSING_PACKAGES + echo "✓ Dependencies installed" +else + echo "✓ All dependencies already installed" +fi + +# Verify dependencies +echo " Verifying dependencies..." +for cmd in git cmake make gcc g++; do + if ! command -v $cmd &> /dev/null; then + echo "ERROR: $cmd is still not available after installation." + exit 1 + fi +done + +# Check Vulkan +if ! pkg-config --exists vulkan; then + echo "ERROR: Vulkan development files not found." + exit 1 +fi + +echo "✓ All dependencies verified" +echo + +# Clone vibevoice.cpp with submodules +echo "[2/5] Cloning vibevoice.cpp repository (with submodules)..." +cd "$TMP_BUILD_DIR" +git clone --recursive https://github.com/localai-org/vibevoice.cpp "$BUILD_DIR" +cd "$BUILD_DIR" +echo "✓ Repository cloned" +echo + +# Build vibevoice.cpp with Vulkan +echo "[3/5] Building vibevoice.cpp with Vulkan support..." +mkdir -p build +cd build + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DVIBEVOICE_VULKAN=ON \ + -DVIBEVOICE_BUILD_TESTS=OFF \ + -DCMAKE_CXX_FLAGS="-march=native -O3" + +cmake --build . -j $(nproc) +echo "✓ Build complete" +echo + +# Copy binaries to output directory +echo "[4/5] Copying binaries..." +mkdir -p "$BIN_DIR" + +if [ -f ./bin/vibevoice-cli ]; then + cp ./bin/vibevoice-cli "$BIN_DIR/" + echo " ✓ vibevoice-cli copied" +fi + +# Copy all vibevoice-* executables if they exist +if ls ./bin/vibevoice-* >/dev/null 2>&1; then + cp ./bin/vibevoice-* "$BIN_DIR/" 2>/dev/null || true + echo " ✓ Additional vibevoice binaries copied" +fi + +# Copy required libraries if they exist +if ls ./lib/* >/dev/null 2>&1; then + mkdir -p "$BIN_DIR/lib" + cp ./lib/* "$BIN_DIR/lib/" 2>/dev/null || true + echo " ✓ Libraries copied" +fi + +echo "✓ Binaries copied to $BIN_DIR" +echo + +# Create simple entrypoint +echo "[5/5] Creating entrypoint script..." +cat > "${SCRIPT_DIR}/entrypoint.sh" << 'EOF' +#!/bin/bash +# Vibevoice.cpp entrypoint for HTTP server or CLI + +set -e + +# If models directory exists and has files, run HTTP server +if [ -d "/app/models" ] && [ "$(ls -A /app/models)" ]; then + echo "=== Vibevoice Server ===" + echo "Models directory: /app/models" + exec /app/vibevoice-cli "$@" +else + echo "⚠ Models directory not found or empty at /app/models" + echo "Please mount your models directory when running the container:" + echo " -v /path/to/models:/app/models" + exec /app/vibevoice-cli "$@" +fi +EOF + +chmod +x "${SCRIPT_DIR}/entrypoint.sh" +echo "✓ Entrypoint script created" +echo + +echo "=== Build Summary ===" +echo "✓ Vibevoice.cpp compiled with Vulkan support" +echo "✓ Binaries location: $BIN_DIR" +echo "✓ Containerfile: vibevoice-vulkan.Containerfile" +echo +echo "Next steps:" +echo " 1. podman build -t vibevoice:vulkan-amd64 -f vibevoice-vulkan.Containerfile ." +echo " 2. podman run -it -v /srv/containers/vibevoice/models:/app/models \\" +echo " vibevoice:vulkan-amd64 tts --model models/vibevoice-realtime-0.5B-q8_0.gguf ..." +echo diff --git a/containers/vibevoice/vibevoice-vulkan.Containerfile b/containers/vibevoice/vibevoice-vulkan.Containerfile new file mode 100644 index 0000000..8c6ce2f --- /dev/null +++ b/containers/vibevoice/vibevoice-vulkan.Containerfile @@ -0,0 +1,47 @@ +### Vibevoice.cpp Container with Vulkan GPU support +### High-performance TTS (Text-to-Speech) + ASR (Speech Recognition) +### Based on vibevoice.cpp: https://github.com/localai-org/vibevoice.cpp +### +### BUILD: ./build-container.sh (compiles locally with Vulkan) +### THEN: podman build -t vibevoice:vulkan-amd64 -f vibevoice-vulkan.Containerfile . + +FROM debian:13-slim + +ARG MODELS=vibevoice-realtime-0.5B + +USER root +EXPOSE 8080 + +RUN apt-get update \ + && apt-get install -y curl ffmpeg nano \ + && apt-get install -y libvulkan1 vulkan-tools mesa-vulkan-drivers libdrm-amdgpu1 \ + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /tmp/* /var/tmp/* \ + && rm -rf /var/lib/apt/lists/* \ + && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ + && find /var/cache -type f -delete + +WORKDIR /app + +# Copy pre-compiled binaries with Vulkan support +COPY bin-vulkan/ /app/ +RUN chmod +x /app/vibevoice-cli /app/vibevoice-* 2>/dev/null || true + +# Copy entrypoint +COPY entrypoint.sh /app/ 2>/dev/null || true +RUN [ -f /app/entrypoint.sh ] && chmod +x /app/entrypoint.sh || true + +# Create models and audio directories (will be mounted as volumes at runtime) +RUN mkdir -p /app/models /app/audio + +# Set environment variables +ENV PATH=/app:$PATH +ENV LD_LIBRARY_PATH=/app:/usr/local/lib:/usr/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH + +# Vulkan environment +ENV VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.json + +# Vibevoice model configuration +ENTRYPOINT ["/app/entrypoint.sh"] +CMD ["--help"] diff --git a/containers/vibevoice/vibevoice.README b/containers/vibevoice/vibevoice.README new file mode 100644 index 0000000..1e622c2 --- /dev/null +++ b/containers/vibevoice/vibevoice.README @@ -0,0 +1,273 @@ +# Vibevoice - TTS (Text-to-Speech) + ASR (Speech Recognition) + +C++ inference engine per Microsoft VibeVoice con supporto per Text-to-Speech con voice cloning e Automatic Speech Recognition con diarizzazione. + +## Requisiti + +- Podman rootless +- Network `internal.network` configurata +- Nginx come reverse proxy +- GPU AMD con Vulkan (opzionale, per performance) +- Spazio disco: almeno 40 GB per i modelli +- Dipendenze di compilazione (cmake, git, gcc, etc.) + +## Build Container + +### 1. Compilare vibevoice.cpp + +```bash +cd /home/badstorm/Source/bdi/bdi_podman_serverconf/containers/vibevoice +./build-container.sh +``` + +Lo script: +- Installa dipendenze (cmake, git, vulkan-dev, glslc, etc.) +- Clona vibevoice.cpp con submoduli +- Compila con supporto Vulkan +- Copia i binari in `bin-vulkan/` +- Crea l'entrypoint + +### 2. Buildare l'immagine Podman + +```bash +podman build -t vibevoice:vulkan-amd64 -f vibevoice-vulkan.Containerfile . +``` + +### 3. Verificare l'immagine + +```bash +podman images | grep vibevoice +podman run --rm vibevoice:vulkan-amd64 --help +``` + +## Setup Runtime + +### 1. Creare le directory di dati + +```bash +mkdir -p /srv/containers/vibevoice/models +mkdir -p /srv/containers/vibevoice/audio +chmod 755 /srv/containers/vibevoice +``` + +### 2. Scaricare i modelli + +I modelli sono disponibili su Hugging Face. Puoi scaricarli in diversi formati: + +**Modelli TTS (Text-to-Speech):** +```bash +# Download vibevoice-realtime-0.5B (più veloce, ~2GB) +cd /srv/containers/vibevoice/models +pip install huggingface-hub +huggingface-cli download mudler/vibevoice.cpp-models \ + vibevoice-realtime-0.5B-q8_0.gguf \ + tokenizer.gguf \ + voice-en-Carter_man.gguf \ + --local-dir . +``` + +**Modelli TTS con Voice Cloning (1.5B):** +```bash +# Download vibevoice-1.5B (supporta voice cloning, ~6.8GB quantizzato) +huggingface-cli download microsoft/VibeVoice-1.5B \ + --local-dir /srv/containers/vibevoice/models/vibevoice-1.5B +``` + +**Modelli ASR (Speech-to-Text):** +```bash +# Download vibevoice-asr (~33GB, quantizzato a Q4_K ~8GB) +huggingface-cli download mudler/vibevoice.cpp-models \ + vibevoice-asr-q4_k.gguf \ + tokenizer.gguf \ + --local-dir . +``` + +### 3. Copiare il file quadlet + +```bash +cp vibevoice.container ~/.config/containers/systemd/ +``` + +### 4. Configurare il dominio + +Modifica il file `~/.config/containers/systemd/vibevoice.container` se necessario per adattare i volumi ai tuoi modelli. + +### 5. Copiare la configurazione Nginx + +```bash +cp vibevoice.nginx /etc/nginx/conf.d/vibevoice.conf +``` + +Modifica il file per sostituire: +- `vibevoice.example.com` con il tuo dominio reale +- Percorsi SSL se diversi da Let's Encrypt default + +### 6. Configurare i certificati SSL + +```bash +sudo certbot certonly --standalone -d vibevoice.tuodominio.com +``` + +### 7. Riavviare Nginx + +```bash +sudo systemctl reload nginx +# oppure per container nginx: +systemctl --user restart nginx +``` + +### 8. Avviare Vibevoice + +```bash +systemctl --user daemon-reload +systemctl --user start vibevoice +systemctl --user enable vibevoice +``` + +## Verifica + +Controlla che il container sia in esecuzione: + +```bash +podman ps | grep vibevoice +``` + +Visualizza i log: + +```bash +podman logs vibevoice +``` + +## Utilizzo CLI + +Vibevoice.cpp fornisce una CLI per TTS e ASR: + +### Text-to-Speech + +```bash +podman exec vibevoice vibevoice-cli tts \ + --model /app/models/vibevoice-realtime-0.5B-q8_0.gguf \ + --tokenizer /app/models/tokenizer.gguf \ + --voice /app/models/voice-en-Carter_man.gguf \ + --text "Hello from vibevoice" \ + --out /app/audio/output.wav +``` + +### Voice Cloning (1.5B) + +```bash +podman exec vibevoice vibevoice-cli tts \ + --model /app/models/vibevoice-1.5B-q8_0.gguf \ + --tokenizer /app/models/tokenizer.gguf \ + --ref-audio /app/audio/reference_voice.wav \ + --text "Hello, I am cloning this voice" \ + --out /app/audio/cloned.wav +``` + +### Multi-Speaker Dialog (1.5B) + +```bash +podman exec vibevoice vibevoice-cli tts \ + --model /app/models/vibevoice-1.5B-q8_0.gguf \ + --tokenizer /app/models/tokenizer.gguf \ + --ref-audio /app/audio/voice_carter.wav \ + --ref-audio /app/audio/voice_emma.wav \ + --text "Speaker 0: Hello, I am Carter. Speaker 1: And I am Emma." \ + --out /app/audio/dialog.wav +``` + +### Automatic Speech Recognition + +```bash +podman exec vibevoice vibevoice-cli asr \ + --model /app/models/vibevoice-asr-q4_k.gguf \ + --tokenizer /app/models/tokenizer.gguf \ + --audio /app/audio/my_audio.wav +``` + +## Modelli Disponibili + +### TTS Models +- **vibevoice-realtime-0.5B**: Modello veloce per TTS real-time con voci preregistrate + - Size: ~2 GB (quantizzato Q8_0) + - Velocità: RTF < 1x su GPU + - Voci: Multiple lingue (en, de, fr, etc.) + +- **vibevoice-1.5B**: Modello con voice cloning e multi-speaker + - Size: ~6.8 GB (quantizzato Q8_0), ~11 GB (float32) + - Caratteristiche: Voice cloning, dialog multi-speaker + - Richiede: ~16GB RAM disponibili + +### ASR Models +- **vibevoice-asr**: Modello per transcription long-form con diarizzazione + - Size: ~33 GB (float32), ~8 GB (quantizzato Q4_K) + - Caratteristiche: Multi-speaker diarizzazione, timestamp precisi + - Lingue: Multiple lingue supportate + +### Quantization Options +```bash +# Q8_0: No quality loss, ~50% size reduction +# Q6_K: Mixed quantization, best quality/size ratio +# Q5_K: Smaller, some quality trade-off +# Q4_K: Smallest, ASR only (TTS non supportato) +``` + +## Performance + +### CPU Benchmarks (AMD Ryzen 9950X3D) +- ASR (68.5s audio): ~2.195 RTF (5.9s load + 150.4s processing) +- TTS: ~1-3s per senso dipendentemente dalla lunghezza + +### GPU Benchmarks (NVIDIA GB10) +- ASR (68.5s audio): ~0.408 RTF (2.2s load + 28s processing) + +### AMD Vulkan (Recommended) +Simile a CUDA per velocità con migliore compatibilità hardware. + +## Troubleshooting + +### Build fails con dipendenze mancanti +```bash +# Esegui lo script con sudo o aggiungi il tuo utente al sudoers +sudo ./build-container.sh +``` + +### Memory Issues durante il build +Se hai meno di 8GB di RAM, il build potrebbe essere lento: +```bash +# Build single-threaded +cmake --build build -j 1 +``` + +### GPU Non Riconosciuta +```bash +# Verifica che il container veda la GPU +podman run --rm --device=/dev/dri --device=/dev/kfd ghcr.io/localai-org/vibevoice rocm-smi +``` + +### Modelli Non Trovati +```bash +# Verifica che il mounting dei volumi sia corretto +podman exec vibevoice ls -la /app/models +``` + +## Aggiornamento + +Per aggiornare a una versione più recente di vibevoice.cpp: + +```bash +# Ricompila +./build-container.sh --no-cache + +# Rebuild immagine +podman build -t vibevoice:vulkan-amd64 -f vibevoice-vulkan.Containerfile . + +# Riavvia container +systemctl --user restart vibevoice +``` + +## References + +- [Vibevoice.cpp GitHub](https://github.com/localai-org/vibevoice.cpp) +- [Models on Hugging Face](https://huggingface.co/mudler/vibevoice.cpp-models) +- [VibeVoice Paper](https://microsoft.github.io/VibeVoice/) diff --git a/containers/vibevoice/vibevoice.container b/containers/vibevoice/vibevoice.container new file mode 100644 index 0000000..8744028 --- /dev/null +++ b/containers/vibevoice/vibevoice.container @@ -0,0 +1,25 @@ +[Unit] +Name=vibevoice +After=network-online.target +Wants=network-online.target + +[Container] +ContainerName=vibevoice +Image=localhost/vibevoice:vulkan-amd64 +#AutoUpdate=registry + +Network=internal.network +#NetworkAlias=vibevoice + +PublishPort=8080:8080 + +# Models directory +Volume=/srv/containers/vibevoice/models:/app/models +Volume=/srv/containers/vibevoice/audio:/app/audio + +[Service] +TimeoutStartSec=5m +Restart=always + +[Install] +WantedBy=multi-user.target default.target diff --git a/containers/vibevoice/vibevoice.nginx b/containers/vibevoice/vibevoice.nginx new file mode 100644 index 0000000..fa2854a --- /dev/null +++ b/containers/vibevoice/vibevoice.nginx @@ -0,0 +1,46 @@ +server { + listen 80; + listen [::]:80; + server_name vibevoice.example.com; + + # Redirect HTTP to HTTPS + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name vibevoice.example.com; + + # SSL Configuration + ssl_certificate /etc/letsencrypt/live/vibevoice.example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/vibevoice.example.com/privkey.pem; + + # SSL Settings + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + + # Large file support for audio + client_max_body_size 100M; + + # Vibevoice upstream (TTS/ASR API) + location / { + proxy_pass http://vibevoice:8080; + proxy_http_version 1.1; + proxy_buffering off; + + # Headers + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Forwarded-Port $server_port; + + # Timeouts for long TTS/ASR processing + proxy_connect_timeout 120s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + } +} diff --git a/containers/whisper/build-container.sh b/containers/whisper/build-container.sh new file mode 100755 index 0000000..93b7ea7 --- /dev/null +++ b/containers/whisper/build-container.sh @@ -0,0 +1,200 @@ +#!/bin/bash +# Build whisper.cpp with Vulkan support and create container image +# This script compiles whisper.cpp locally and creates a Podman image +# Usage: ./build-container.sh [--no-cache] + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TMP_BUILD_DIR="${SCRIPT_DIR}/.tmp" +BUILD_DIR="${TMP_BUILD_DIR}/whisper" +BIN_DIR="${TMP_BUILD_DIR}/bin-vulkan" +MODELS_DIR="${TMP_BUILD_DIR}/models" +HOME_DIR="${HOME}" +NO_CACHE="" +EXIT_CODE=0 + +# Cleanup function - always runs on exit +cleanup() { + local exit_code=$? + if [ $exit_code -ne 0 ]; then + echo + echo "⚠ Build failed (exit code: $exit_code). Cleaning up temporary files..." + fi + rm -rf "$TMP_BUILD_DIR" "${SCRIPT_DIR}/bin-vulkan" "${SCRIPT_DIR}/models" 2>/dev/null || true + if [ $exit_code -eq 0 ]; then + echo "✓ Cleanup complete" + fi + return $exit_code +} + +# Set trap to cleanup on exit (success or failure) +trap cleanup EXIT + +# Parse arguments +if [[ "$1" == "--no-cache" ]]; then + NO_CACHE="--no-cache" + echo "Build mode: NO CACHE (clean rebuild)" +fi + +echo "=== Whisper.cpp Vulkan Build ===" +echo "Temporary build directory: $TMP_BUILD_DIR" +echo "Output directory: $BIN_DIR" +echo "Home directory: $HOME_DIR" +if [ -n "$NO_CACHE" ]; then + echo "Cache mode: DISABLED" +fi +echo + +# Create temporary build directory +mkdir -p "$TMP_BUILD_DIR" +echo + +# Install dependencies +echo "[1/6] Installing dependencies..." +REQUIRED_PACKAGES="build-essential cmake git libvulkan-dev vulkan-tools glslc spirv-headers spirv-tools python3" +MISSING_PACKAGES="" + +for pkg in $REQUIRED_PACKAGES; do + if ! dpkg -l | grep -q "^ii $pkg"; then + MISSING_PACKAGES="$MISSING_PACKAGES $pkg" + fi +done + +if [ -n "$MISSING_PACKAGES" ]; then + echo " Installing missing packages:$MISSING_PACKAGES" + sudo apt-get update + sudo apt-get install -y $MISSING_PACKAGES + echo "✓ Dependencies installed" +else + echo "✓ All dependencies already installed" +fi + +# Verify dependencies +echo " Verifying dependencies..." +for cmd in git cmake make gcc g++; do + if ! command -v $cmd &> /dev/null; then + echo "ERROR: $cmd is still not available after installation." + exit 1 + fi +done + +# Check Vulkan +if ! pkg-config --exists vulkan; then + echo "ERROR: Vulkan development files not found." + exit 1 +fi + +if ! command -v glslc &> /dev/null; then + echo "ERROR: glslc (GLSL compiler) not found. Install with: sudo apt install glslc" + exit 1 +fi + +echo "✓ All dependencies verified" +echo + +# Clone or update whisper.cpp +echo "[2/6] Cloning/updating whisper.cpp repository..." +if [ -d "$BUILD_DIR" ]; then + echo " Updating existing repository..." + cd "$BUILD_DIR" + git fetch origin + git checkout master + git pull origin master +else + echo " Cloning whisper.cpp..." + git clone https://github.com/ggml-org/whisper.cpp.git "$BUILD_DIR" + cd "$BUILD_DIR" +fi +echo "✓ Repository ready" +echo + +# Build with Vulkan support +echo "[3/6] Building with Vulkan support (this may take a few minutes)..." +mkdir -p build +cd build + +# Clean if --no-cache is specified +if [ -n "$NO_CACHE" ]; then + echo " Cleaning previous build..." + rm -rf * .cmake +fi + +cmake .. -DGGML_VULKAN=1 -DWHISPER_COMMON_FFMPEG=yes -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF +cmake --build . -j $(nproc) --config Release +echo "✓ Build complete" +echo + +# Prepare binary directory +echo "[4/6] Preparing binary directory..." +mkdir -p "$BIN_DIR" +cd "$BUILD_DIR" + +# Copy binaries +echo " Copying binaries..." +cp build/bin/whisper-cli "$BIN_DIR/" +cp build/bin/whisper-server "$BIN_DIR/" +cp build/bin/whisper-bench "$BIN_DIR/" +cp build/bin/whisper-quantize "$BIN_DIR/" +chmod +x "$BIN_DIR"/* + +# Copy model download script +mkdir -p "$MODELS_DIR" +cp models/download-ggml-model.sh "$MODELS_DIR/" +chmod +x "$MODELS_DIR/download-ggml-model.sh" + +# Download default model if not present +if [ ! -f "$MODELS_DIR/ggml-base.en.bin" ]; then + echo " Downloading base.en model (~140MB)..." + cd "$MODELS_DIR" + ./download-ggml-model.sh base.en -o . >/dev/null 2>&1 || { + echo " ⚠ Model download failed, you can download it manually later" + echo " Command: $MODELS_DIR/download-ggml-model.sh base.en -o $MODELS_DIR" + } +else + echo " Model already present: ggml-base.en.bin" +fi + +echo "✓ Binaries ready" +echo + +# Build Podman image +echo "[5/6] Building Podman image..." + +# Copy Containerfile and entrypoint to .tmp for build +echo " Preparing build context..." +cp "${SCRIPT_DIR}/whisper-vulkan.Containerfile" "${TMP_BUILD_DIR}/" +cp "${SCRIPT_DIR}/entrypoint.sh" "${TMP_BUILD_DIR}/" + +# Build from within .tmp - everything stays isolated +cd "$TMP_BUILD_DIR" +podman build $NO_CACHE -t whisper:vulkan-amd64 -f whisper-vulkan.Containerfile . +echo "✓ Podman image built" +echo + +# Save image to home directory +echo "[6/6] Saving image to $HOME_DIR..." +IMAGE_FILE="$HOME_DIR/whisper-vulkan-amd64.tar" +podman save -o "$IMAGE_FILE" localhost/whisper:vulkan-amd64 +IMAGE_SIZE=$(du -h "$IMAGE_FILE" | cut -f1) +echo "✓ Image saved: $IMAGE_FILE ($IMAGE_SIZE)" +echo + +echo "=== BUILD COMPLETE ===" +echo +echo "✓ Container image created: whisper:vulkan-amd64" +echo "✓ Image saved: $IMAGE_FILE" +echo +echo "Next steps:" +echo " 1. Load the image locally:" +echo " podman load -i $IMAGE_FILE" +echo +echo " 2. Install as systemd service:" +echo " podman container runlabel install -n whisper whisper.container localhost/whisper:vulkan-amd64" +echo " systemctl --user daemon-reload" +echo " systemctl --user enable whisper" +echo " systemctl --user start whisper" +echo +echo " 3. Or run directly:" +echo " podman run --device /dev/dri/renderD128 -p 8080:8080 -v /path/to/models:/app/models whisper:vulkan-amd64" +echo diff --git a/containers/whisper/entrypoint.sh b/containers/whisper/entrypoint.sh new file mode 100644 index 0000000..be6074a --- /dev/null +++ b/containers/whisper/entrypoint.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# Whisper entrypoint script +# Downloads model if not present, then starts whisper-server + +set -e + +MODEL_PATH="/app/models/${WHISPER_MODEL_FILE:-ggml-small.bin}" +MODEL_NAME="${WHISPER_MODEL_NAME:-small}" +WHISPER_LANGUAGE="${WHISPER_LANGUAGE:-auto}" +WHISPER_TRANSLATE="${WHISPER_TRANSLATE:-false}" +WHISPER_DETECT_LANGUAGE="${WHISPER_DETECT_LANGUAGE:-false}" +WHISPER_DTW="${WHISPER_DTW:-}" + +echo "=== Whisper Server ===" +echo "Model: $MODEL_NAME" +echo "Path: $MODEL_PATH" +echo "Language: $WHISPER_LANGUAGE" +echo "Translate: $WHISPER_TRANSLATE" +echo "Detect Language: $WHISPER_DETECT_LANGUAGE" +echo "DTW: ${WHISPER_DTW:-disabled}" +echo + +# Check if model exists +if [ ! -f "$MODEL_PATH" ]; then + echo "Model not found. Downloading $MODEL_NAME..." + if ! /app/download-ggml-model.sh "$MODEL_NAME" /app/models; then + echo "ERROR: Failed to download model $MODEL_NAME" + exit 1 + fi + if [ ! -f "$MODEL_PATH" ]; then + echo "ERROR: Model file not found after download" + ls -la /app/models/ + exit 1 + fi + echo "✓ Model downloaded" +else + echo "✓ Model found" +fi + +echo "Starting whisper-server on port 8080..." +echo + +# Build whisper-server arguments +WHISPER_ARGS=( + --host 0.0.0.0 + --port 8080 + -m "$MODEL_PATH" + -l "$WHISPER_LANGUAGE" +) + +# Add optional flags +if [ "$WHISPER_TRANSLATE" = "true" ]; then + WHISPER_ARGS+=(--translate) +fi + +if [ "$WHISPER_DETECT_LANGUAGE" = "true" ]; then + WHISPER_ARGS+=(--detect-language) +fi + +if [ -n "$WHISPER_DTW" ]; then + WHISPER_ARGS+=(--dtw "$WHISPER_DTW") + WHISPER_ARGS+=(--no-flash-attn) +fi + +# Start whisper-server with all arguments and any additional args passed to this script +exec /app/whisper-server "${WHISPER_ARGS[@]}" "$@" diff --git a/containers/whisper/whisper-vulkan.Containerfile b/containers/whisper/whisper-vulkan.Containerfile new file mode 100644 index 0000000..13d0da7 --- /dev/null +++ b/containers/whisper/whisper-vulkan.Containerfile @@ -0,0 +1,57 @@ +### Whisper.cpp Container with Vulkan GPU support +### High-performance Speech-to-Text using OpenAI's Whisper model +### Based on whisper.cpp: https://github.com/ggml-org/whisper.cpp +### +### BUILD: ./build-container.sh (compiles locally with Vulkan) +### THEN: podman build -t whisper:vulkan-amd64 -f whisper-vulkan.Containerfile . +### With custom model: podman build --build-arg MODELS="small" -t whisper:vulkan-amd64 -f whisper-vulkan.Containerfile . + +FROM debian:13-slim +#FROM ubuntu:26.04-slim + +ARG MODELS=small + +USER root +EXPOSE 8080 + +RUN apt-get update \ + && apt-get install -y curl ffmpeg nano \ + && apt-get install -y libvulkan1 vulkan-tools mesa-vulkan-drivers libdrm-amdgpu1 \ + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /tmp/* /var/tmp/* \ + && rm -rf /var/lib/apt/lists/* \ + && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ + && find /var/cache -type f -delete + +WORKDIR /app + +# Copy pre-compiled binaries with Vulkan support +COPY bin-vulkan/ /app/ +RUN chmod +x /app/whisper-* + +# Copy models downloader and entrypoint +COPY models/download-ggml-model.sh /app/ +COPY entrypoint.sh /app/ +RUN chmod +x /app/download-ggml-model.sh /app/entrypoint.sh + +# Create models directory (will be mounted as volume at runtime) +RUN mkdir -p /app/models + +# Set environment variables +ENV PATH=/app:$PATH +ENV LD_LIBRARY_PATH=/app:/usr/local/lib:/usr/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH +ENV HF_HUB_ENABLE_HF_TRANSFER=1 + +# Vulkan environment +ENV VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.json + +# Whisper model configuration +# MODELS arg is passed but not used during build (downloaded at runtime) +ENV WHISPER_MODEL_NAME=${MODELS} +ENV WHISPER_MODEL_FILE=ggml-${MODELS}.bin + +WORKDIR /app + +ENTRYPOINT ["/app/entrypoint.sh"] +CMD [] diff --git a/containers/whisper/whisper-vulkan.README b/containers/whisper/whisper-vulkan.README new file mode 100644 index 0000000..7b359ec --- /dev/null +++ b/containers/whisper/whisper-vulkan.README @@ -0,0 +1,140 @@ +# Whisper.cpp - Speech-to-Text with Vulkan GPU + +High-performance Speech-to-Text using OpenAI's Whisper model with Vulkan GPU acceleration. + +## Quick Start + +### 1. Build + +```bash +cd Services/Whisper +./build-container.sh +``` + +Done! The image is ready. + +### 2. Run + +```bash +podman run --device /dev/dri/renderD128 -p 8080:8080 \ + -v /srv/whisper/models:/app/models \ + whisper:vulkan-amd64 +``` + +Default model is `small` (downloads on first start). + +**Change model without rebuilding:** +```bash +podman run --device /dev/dri/renderD128 -p 8080:8080 \ + -v /srv/whisper/models:/app/models \ + -e WHISPER_MODEL_NAME=medium \ + whisper:vulkan-amd64 +``` + +### 3. Transcribe + +**JSON output:** +```bash +curl -F "file=@audio.wav" http://localhost:8080/inference > result.json +``` + +**Extract text to file:** +```bash +curl -F "file=@audio.wav" http://localhost:8080/inference | jq -r '.text' > transcript.txt +``` + +**Supported formats:** .wav, .mp3, .ogg, .flac, .opus + +## Available Models + +Set with: `WHISPER_MODEL_NAME=` + +| Model | Size | Speed | Memory | Default | +|-------|------|-------|--------|---------| +| small | 466 MB | Good | ~1.1 GB | ✓ |for file in *.opus; do + ffmpeg -i "$file" -acodec pcm_s16le "${file%.opus}.wav" -y +done +| medium | 775 MB | Better | ~1.2 GB | | +| large-v3 | 2.9 GB | Best | ~3.9 GB | | + +Models auto-download on first use. + +### Change Model at Runtime + +```bash +# Run with medium instead of small +podman run -e WHISPER_MODEL_NAME=medium whisper:vulkan-amd64 + +# Change in systemd service (edit whisper.container) +Environment=WHISPER_MODEL_NAME=medium +``` + +## Basic Commands + +```bash +# Transcribe (uses configured model) +podman exec whisper whisper-cli -m /app/models/ggml-small.bin -f audio.wav + +# Benchmark +podman exec whisper whisper-bench -m /app/models/ggml-small.bin + +# Check logs +podman logs whisper +``` + +## Systemd Service + +```bash +# Install +podman container runlabel install -n whisper whisper.container localhost/whisper:vulkan-amd64 + +# Enable and start +systemctl --user enable --now whisper + +# Check status +systemctl --user status whisper +``` + +## Troubleshooting + +**GPU not detected:** +```bash +podman run --device /dev/dri/renderD128 --rm whisper:vulkan-amd64 vulkaninfo +``` + +**WSL2 (GPU device and Vulkan drivers):** + +WSL2 uses different GPU device paths and Vulkan drivers come from WSLg. You may need to: + +```bash +# Option 1: Mount WSL GPU libraries +podman run --device /dev/dri/dgx \ + -v /usr/lib/wsl:/usr/lib/wsl:ro \ + -p 8080:8080 \ + -v /srv/whisper/models:/app/models \ + whisper:vulkan-amd64 + +# Option 2: If Option 1 fails, also mount vulkan drivers +podman run --device /dev/dri/dgx \ + -v /usr/lib/wsl:/usr/lib/wsl:ro \ + -v /usr/share/vulkan:/usr/share/vulkan:ro \ + -p 8080:8080 \ + -v /srv/whisper/models:/app/models \ + -e VK_DRIVER_FILES=/usr/share/vulkan/icd.d/icd.json \ + whisper:vulkan-amd64 + +# Find the correct GPU device: +ls /dev/dri/ +# Usually: /dev/dri/dgx for GPU +``` + +**Out of memory:** +Use `medium-q5` instead of `large-v3` + +## References + +- [whisper.cpp](https://github.com/ggml-org/whisper.cpp) +- [Vulkan](https://www.khronos.org/vulkan/) + + + diff --git a/containers/whisper/whisper-wsl.container b/containers/whisper/whisper-wsl.container new file mode 100644 index 0000000..0fde664 --- /dev/null +++ b/containers/whisper/whisper-wsl.container @@ -0,0 +1,35 @@ +[Container] +ContainerName=whisper +Image=localhost/whisper:vulkan-amd64 +#AutoUpdate=registry +Network=internal.network +PublishPort=8080:8080 + +# Production - Cache dei modelli +Volume=/srv/containers/whisper/models:/app/models + +# WSL2 Vulkan GPU support +AddDevice=/dev/dxg +# Mount WSL Vulkan driver libraries +Volume=/usr/lib/wsl:/usr/lib/wsl:ro +Volume=/usr/share/vulkan:/usr/share/vulkan:ro +PodmanArgs=--group-add=keep-groups --ipc=host +SecurityLabelType=container_runtime_t + +# Whisper configuration +Environment=WHISPER_MODEL_NAME=small +Environment=WHISPER_MODEL_FILE=ggml-small.bin +Environment=WHISPER_LANGUAGE=auto +Environment=WHISPER_TRANSLATE=false +Environment=WHISPER_DETECT_LANGUAGE=false +Environment=HF_HOME=/app/models/.huggingface +Environment=HF_HUB_ENABLE_HF_TRANSFER=1 +# WSL2 Vulkan driver configuration +Environment=VK_DRIVER_FILES=/usr/share/vulkan/icd.d/icd.json + +[Service] +Restart=on-failure +TimeoutStartSec=10m + +[Install] +WantedBy=multi-user.target default.target diff --git a/containers/whisper/whisper.container b/containers/whisper/whisper.container new file mode 100644 index 0000000..8b798a8 --- /dev/null +++ b/containers/whisper/whisper.container @@ -0,0 +1,36 @@ +[Container] +ContainerName=whisper +Image=localhost/whisper:vulkan-amd64 +#AutoUpdate=registry +Network=internal.network +PublishPort=8080:8080 + +# Production - Cache dei modelli +Volume=/srv/containers/whisper/models:/app/models + +# Vulkan GPU support +AddDevice=/dev/dri/renderD128 +Volume=/usr/share/vulkan:/usr/share/vulkan:ro +PodmanArgs=--group-add=keep-groups --ipc=host +SecurityLabelType=container_runtime_t + +# Whisper configuration +Environment=WHISPER_MODEL_NAME=small +Environment=WHISPER_MODEL_FILE=ggml-small.bin +Environment=WHISPER_LANGUAGE=auto +Environment=WHISPER_TRANSLATE=false +Environment=WHISPER_DTW=large.v3 + +Environment=WHISPER_DETECT_LANGUAGE=false +Environment=HF_HOME=/app/models/.huggingface +Environment=HF_HUB_ENABLE_HF_TRANSFER=1 +Environment=VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.json +Environment=LD_LIBRARY_PATH=/app:/usr/local/lib:/usr/lib:/usr/lib/x86_64-linux-gnu + + +[Service] +Restart=on-failure +TimeoutStartSec=10m + +[Install] +WantedBy=multi-user.target default.target diff --git a/install.sh b/install.sh deleted file mode 100644 index af8f2f7..0000000 --- a/install.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash - -set -e - -# Modifica questa variabile con l'URL raw del tuo repository remoto -REPO_URL="https://code.badstorm.xyz/SRV/bdi_podman_serverconf/raw/main" - -echo "Iniziando l'installazione di BDI Podman Serverconf..." - -# 1. Aggiornare il sistema Ubuntu -echo "Aggiornando il sistema..." -sudo apt update && sudo apt upgrade -y - -# 2. Aggiungere utente ai gruppi render e video -echo "Aggiungendo utente ai gruppi render e video..." -sudo usermod -a -G render,video $LOGNAME -sudo loginctl enable-linger $USER -sudo sh -c "echo 'net.ipv4.ip_unprivileged_port_start=80' >> /etc/sysctl.conf" - - -# 3. Installare podman -echo "Installando podman..." -sudo apt install -y podman htop radeontop curl - -# 4. Creare cartelle per systemd containers -echo "Creando cartelle per containers systemd..." -mkdir -p ~/.config/containers/systemd - -# 5. Scaricare e copiare internal.network -echo "Scaricando internal.network..." -curl -fsSL $REPO_URL/internal.network -o ~/.config/containers/systemd/internal.network - -# 6. Aggiungere registri a /etc/containers/registries.conf -echo "Aggiungendo registri a registries.conf..." -printf "[registries.search]\nregistries = [\"docker.io\", \"quay.io\", \"ghcr.io\"]\n" | sudo tee -a /etc/containers/registries.conf > /dev/null - -# 7. Creare /srv/containers e assegnare permessi -echo "Creando /srv/containers e assegnando permessi..." -sudo mkdir -p /srv/containers -sudo chown -R $LOGNAME /srv/containers - -# 8. Creare sottocartelle per aitools -echo "Creando cartelle per aitools..." -mkdir -p /srv/containers/aitools/models -mkdir -p /srv/containers/aitools/.cache - -# 9. Creare file vuoto llamacpp_config.yaml -echo "Creando llamacpp_config.yaml..." -touch /srv/containers/aitools/llamacpp_config.yaml - -# 10. Aggiornare GRUB -echo "Aggiornando GRUB..." -if [ -t 0 ]; then - echo "Seleziona la quantità di RAM (16, 24, 32, 48 GB):" - read ram_gb -else - echo "Modalità non interattiva: usando default 32GB" - ram_gb=32 -fi -case $ram_gb in - 16) - gttsize=16384 - pages_limit=18432000 - ;; - 24) - gttsize=24576 - pages_limit=27648000 - ;; - 32) - gttsize=32768 - pages_limit=36864000 - ;; - 48) - gttsize=49152 - pages_limit=55296000 - ;; - *) - echo "Valore non valido, usando default 32GB" - gttsize=32768 - pages_limit=36864000 - ;; -esac -sudo sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"amdgpu.gttsize=${gttsize} amdttm.pages_limit=${pages_limit}\"/" /etc/default/grub -sudo update-grub - -# 11. Scaricare e installare banner.sh -echo "Scaricando e installando banner MOTD..." -sudo curl -fsSL $REPO_URL/BadAI/banner.sh -o /etc/update-motd.d/99-badai-banner -sudo chmod +x /etc/update-motd.d/99-badai-banner - -# 12. Disabilitare altri script MOTD -echo "Disabilitando altri script MOTD..." -sudo bash -c 'for f in /etc/update-motd.d/*; do if [[ "$f" != "/etc/update-motd.d/99-badai-banner" && ! -f "${f}.disabled" ]]; then mv "$f" "${f}.disabled"; fi; done' - -# 13. Sostituire /etc/issue -echo "Sostituendo /etc/issue..." -sudo curl -fsSL $REPO_URL/BadAI/issue -o /etc/issue - -# 14. Scaricare e installare badai -echo "Scaricando e installando badai..." -sudo curl -fsSL $REPO_URL/BadAI/badai -o /usr/local/bin/badai -sudo chmod +x /usr/local/bin/badai - -# 15. Scaricare container files -echo "Scaricando file container..." -curl -fsSL $REPO_URL/Services/llamacpp/llamacpp.container -o ~/.config/containers/systemd/llamacpp.container -curl -fsSL $REPO_URL/Services/nginx/nginx.container -o ~/.config/containers/systemd/nginx.container - -# 16. Riavviare il sistema -echo "Installazione completata. Riavviando il sistema..." -sudo reboot \ No newline at end of file diff --git a/internal.network b/internal.network deleted file mode 100644 index 5ac3f97..0000000 --- a/internal.network +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Internal network for containers -After=network-online.target - -[Network] -NetworkName=internal -Subnet=10.10.0.0/24 -Gateway=10.10.0.1 -DNS=9.9.9.9 - -[Install] -WantedBy=default.target \ No newline at end of file