From 0ce1dd65ccc6eb9dba904dc71f7fcccd2794d982 Mon Sep 17 00:00:00 2001 From: BadStorm Date: Sun, 23 Nov 2025 18:54:35 +0100 Subject: [PATCH] Add lemonade --- .../lemonade/lemonade-ubuntu.Containerfile | 32 ++++++++++++++ Services/lemonade/lemonade.container | 31 +++++++++++++ Services/lemonade/lemonade.fix-proxy.sh | 43 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 Services/lemonade/lemonade-ubuntu.Containerfile create mode 100644 Services/lemonade/lemonade.container create mode 100644 Services/lemonade/lemonade.fix-proxy.sh diff --git a/Services/lemonade/lemonade-ubuntu.Containerfile b/Services/lemonade/lemonade-ubuntu.Containerfile new file mode 100644 index 0000000..bf5a02a --- /dev/null +++ b/Services/lemonade/lemonade-ubuntu.Containerfile @@ -0,0 +1,32 @@ +# 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 +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//') && \ + wget -O /tmp/lemonade-server-minimal.deb \ + https://github.com/lemonade-sdk/lemonade/releases/download/v${VERSION}/lemonade-server-minimal_${VERSION}_amd64.deb && \ + 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 + +# Se nel tuo base usi un utente non-root (es. appuser), scommenta: +# USER appuser + +ENTRYPOINT ["lemonade-server"] +CMD ["serve", "--port", "8000", "--host", "0.0.0.0", "--ctx-size", "131072", "--llamacpp", "vulkan"] diff --git a/Services/lemonade/lemonade.container b/Services/lemonade/lemonade.container new file mode 100644 index 0000000..cfbbe2a --- /dev/null +++ b/Services/lemonade/lemonade.container @@ -0,0 +1,31 @@ +[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 + +# 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_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 new file mode 100644 index 0000000..057368f --- /dev/null +++ b/Services/lemonade/lemonade.fix-proxy.sh @@ -0,0 +1,43 @@ +#!/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