4
This commit is contained in:
@@ -1,26 +1,24 @@
|
|||||||
FROM localai/localai:latest-cpu
|
ARG BUILD_FROM
|
||||||
|
FROM $BUILD_FROM
|
||||||
|
|
||||||
|
# Installer LocalAI
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
curl \
|
||||||
|
bash \
|
||||||
|
&& curl -Lo /usr/local/bin/local-ai \
|
||||||
|
"https://github.com/mudler/LocalAI/releases/latest/download/local-ai-Linux-x86_64" \
|
||||||
|
&& chmod +x /usr/local/bin/local-ai
|
||||||
|
|
||||||
|
# Variables d'environnement pour LocalAI
|
||||||
ENV LOCALAI_P2P="true"
|
ENV LOCALAI_P2P="true"
|
||||||
ENV LOCALAI_FEDERATED="true"
|
ENV LOCALAI_FEDERATED="true"
|
||||||
|
ENV LOCALAI_P2P_LISTEN_PORT="9090"
|
||||||
|
ENV LOCALAI_ADDRESS="0.0.0.0:8080"
|
||||||
|
ENV LOCALAI_CORS="true"
|
||||||
|
ENV LOCALAI_CORS_ALLOW_ORIGINS="*"
|
||||||
|
|
||||||
# Installer bashio pour accéder à la configuration Home Assistant
|
# Copier le script de démarrage
|
||||||
RUN apt-get update && \
|
COPY run.sh /usr/bin/run.sh
|
||||||
apt-get install -y --no-install-recommends \
|
RUN chmod +x /usr/bin/run.sh
|
||||||
curl jq && \
|
|
||||||
curl -J -L -o /tmp/bashio.tar.gz \
|
|
||||||
"https://github.com/hassio-addons/bashio/archive/v0.16.2.tar.gz" && \
|
|
||||||
mkdir /tmp/bashio && \
|
|
||||||
tar zxvf /tmp/bashio.tar.gz --strip 1 -C /tmp/bashio && \
|
|
||||||
mv /tmp/bashio/lib /usr/lib/bashio && \
|
|
||||||
ln -s /usr/lib/bashio/bashio /usr/bin/bashio && \
|
|
||||||
rm -rf /tmp/bashio* && \
|
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY run.sh /build/custom-entrypoint.sh
|
CMD ["/usr/bin/run.sh"]
|
||||||
RUN chmod +x /build/custom-entrypoint.sh
|
|
||||||
|
|
||||||
# Remplacer l'entrypoint par défaut
|
|
||||||
ENTRYPOINT ["/build/custom-entrypoint.sh"]
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
name: "LocalAI P2P Master"
|
name: "LocalAI P2P Master"
|
||||||
version: "1.0.1"
|
version: "1.0.2"
|
||||||
slug: "localai-p2p-master"
|
slug: "localai-p2p-master"
|
||||||
description: "LocalAI with P2P federation support (master node with GPU)"
|
description: "LocalAI with P2P federation support (master node with GPU)"
|
||||||
url: "https://git.carriere.cloud/alex/hass-addons/tree/main/localai-p2p-master"
|
url: "https://git.carriere.cloud/alex/hass-addons/tree/main/localai-p2p-master"
|
||||||
arch:
|
arch:
|
||||||
- amd64
|
- amd64
|
||||||
|
build_from:
|
||||||
|
amd64: "ghcr.io/hassio-addons/base/amd64:15.0.7"
|
||||||
host_network: true
|
host_network: true
|
||||||
startup: application
|
startup: application
|
||||||
ingress: true
|
ingress: true
|
||||||
@@ -36,7 +38,9 @@ options:
|
|||||||
gpu_layers: 99
|
gpu_layers: 99
|
||||||
debug: false
|
debug: false
|
||||||
models_path: "/share/localai/models"
|
models_path: "/share/localai/models"
|
||||||
|
threads: 8
|
||||||
schema:
|
schema:
|
||||||
gpu_layers: "int(0,)"
|
gpu_layers: "int(0,)"
|
||||||
debug: "bool?"
|
debug: "bool?"
|
||||||
models_path: "str?"
|
models_path: "str?"
|
||||||
|
threads: "int(1,)"
|
||||||
|
|||||||
@@ -1,51 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/with-contenv bashio
|
||||||
|
|
||||||
# Forcer l'utilisation de la configuration Home Assistant
|
# Les variables d'environnement sont automatiquement disponibles depuis les options
|
||||||
echo "Using Home Assistant configuration"
|
echo "Starting LocalAI P2P Master"
|
||||||
|
echo "GPU Layers: $(bashio::config 'gpu_layers')"
|
||||||
|
echo "Models Path: $(bashio::config 'models_path')"
|
||||||
|
|
||||||
# Vérifier que bashio est disponible
|
# Créer le répertoire des modèles
|
||||||
if [ -f /usr/bin/bashio ]; then
|
MODELS_PATH="$(bashio::config 'models_path')"
|
||||||
echo "DEBUG: bashio found, reading configuration"
|
|
||||||
GPU_LAYERS="$(bashio config gpu_layers 2>/dev/null || echo '99')"
|
|
||||||
TOKEN="$(bashio config master_token 2>/dev/null || echo '')"
|
|
||||||
MODELS_PATH="$(bashio config models_path 2>/dev/null || echo '/share/localai/models')"
|
|
||||||
else
|
|
||||||
echo "DEBUG: bashio not found, using defaults"
|
|
||||||
GPU_LAYERS="99"
|
|
||||||
TOKEN=""
|
|
||||||
MODELS_PATH="/share/localai/models"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "DEBUG: GPU_LAYERS=$GPU_LAYERS"
|
|
||||||
echo "DEBUG: TOKEN from config: '$TOKEN'"
|
|
||||||
echo "DEBUG: MODELS_PATH=$MODELS_PATH"
|
|
||||||
|
|
||||||
# Forcer l'utilisation du token si fourni
|
|
||||||
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then
|
|
||||||
echo "DEBUG: Setting LOCALAI_P2P_TOKEN to: $TOKEN"
|
|
||||||
export LOCALAI_P2P_TOKEN="$TOKEN"
|
|
||||||
export P2P_TOKEN="$TOKEN"
|
|
||||||
else
|
|
||||||
echo "DEBUG: No valid token provided in configuration"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "DEBUG: LOCALAI_P2P_TOKEN is set to: '$LOCALAI_P2P_TOKEN'"
|
|
||||||
echo "DEBUG: P2P_TOKEN is set to: '$P2P_TOKEN'"
|
|
||||||
|
|
||||||
# Créer le répertoire des modèles s'il n'existe pas
|
|
||||||
mkdir -p "$MODELS_PATH"
|
mkdir -p "$MODELS_PATH"
|
||||||
|
|
||||||
# Nettoyer les fichiers de configuration corrompus
|
# Nettoyer les fichiers corrompus
|
||||||
echo "DEBUG: Cleaning corrupted config files in $MODELS_PATH"
|
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; 2>/dev/null | xargs rm -f 2>/dev/null || true
|
||||||
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; | while read file; do
|
|
||||||
echo "DEBUG: Removing corrupted file: $file"
|
|
||||||
rm -f "$file"
|
|
||||||
done 2>/dev/null || true
|
|
||||||
|
|
||||||
# Définir les variables d'environnement pour LocalAI
|
# Configurer les threads
|
||||||
export THREADS="${THREADS:-8}"
|
export THREADS="$(bashio::config 'threads' || echo '8')"
|
||||||
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-8}"
|
export OMP_NUM_THREADS="$THREADS"
|
||||||
|
|
||||||
# Lancer LocalAI avec nos paramètres
|
# Lancer LocalAI (master génère automatiquement un token)
|
||||||
echo "DEBUG: Starting LocalAI with models-path=$MODELS_PATH, threads=$THREADS"
|
echo "Starting LocalAI Master with models path: $MODELS_PATH"
|
||||||
exec /build/local-ai run --models-path="$MODELS_PATH" --threads="$THREADS" --address="0.0.0.0:8080" --cors --cors-allow-origins="*"
|
echo "P2P Token will be generated automatically"
|
||||||
|
exec /usr/local/bin/local-ai run \
|
||||||
|
--models-path="$MODELS_PATH" \
|
||||||
|
--threads="$THREADS" \
|
||||||
|
--address="0.0.0.0:8080" \
|
||||||
|
--cors \
|
||||||
|
--cors-allow-origins="*"
|
||||||
|
|||||||
@@ -1,26 +1,24 @@
|
|||||||
FROM localai/localai:latest-cpu
|
ARG BUILD_FROM
|
||||||
|
FROM $BUILD_FROM
|
||||||
|
|
||||||
|
# Installer LocalAI
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
curl \
|
||||||
|
bash \
|
||||||
|
&& curl -Lo /usr/local/bin/local-ai \
|
||||||
|
"https://github.com/mudler/LocalAI/releases/latest/download/local-ai-Linux-x86_64" \
|
||||||
|
&& chmod +x /usr/local/bin/local-ai
|
||||||
|
|
||||||
|
# Variables d'environnement pour LocalAI
|
||||||
ENV LOCALAI_P2P="true"
|
ENV LOCALAI_P2P="true"
|
||||||
ENV LOCALAI_FEDERATED="true"
|
ENV LOCALAI_FEDERATED="true"
|
||||||
|
ENV LOCALAI_P2P_LISTEN_PORT="9090"
|
||||||
|
ENV LOCALAI_ADDRESS="0.0.0.0:8080"
|
||||||
|
ENV LOCALAI_CORS="true"
|
||||||
|
ENV LOCALAI_CORS_ALLOW_ORIGINS="*"
|
||||||
|
|
||||||
# Installer bashio pour accéder à la configuration Home Assistant
|
# Copier le script de démarrage
|
||||||
RUN apt-get update && \
|
COPY run.sh /usr/bin/run.sh
|
||||||
apt-get install -y --no-install-recommends \
|
RUN chmod +x /usr/bin/run.sh
|
||||||
curl jq && \
|
|
||||||
curl -J -L -o /tmp/bashio.tar.gz \
|
|
||||||
"https://github.com/hassio-addons/bashio/archive/v0.16.2.tar.gz" && \
|
|
||||||
mkdir /tmp/bashio && \
|
|
||||||
tar zxvf /tmp/bashio.tar.gz --strip 1 -C /tmp/bashio && \
|
|
||||||
mv /tmp/bashio/lib /usr/lib/bashio && \
|
|
||||||
ln -s /usr/lib/bashio/bashio /usr/bin/bashio && \
|
|
||||||
rm -rf /tmp/bashio* && \
|
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY run.sh /build/custom-entrypoint.sh
|
CMD ["/usr/bin/run.sh"]
|
||||||
RUN chmod +x /build/custom-entrypoint.sh
|
|
||||||
|
|
||||||
# Remplacer l'entrypoint par défaut
|
|
||||||
ENTRYPOINT ["/build/custom-entrypoint.sh"]
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
name: "LocalAI P2P Worker"
|
name: "LocalAI P2P Worker"
|
||||||
version: "1.0.3.9" # Incrémentez aussi la version
|
version: "1.0.4"
|
||||||
slug: "localai-p2p-worker" # ⬅️ IMPORTANT : doit correspondre au nom du dossier
|
slug: "localai-p2p-worker"
|
||||||
description: "LocalAI P2P federation worker node"
|
description: "LocalAI P2P federation worker node"
|
||||||
arch:
|
arch:
|
||||||
- amd64
|
- amd64
|
||||||
|
build_from:
|
||||||
|
amd64: "ghcr.io/hassio-addons/base/amd64:15.0.7"
|
||||||
host_network: true # OBLIGATOIRE pour P2P
|
host_network: true # OBLIGATOIRE pour P2P
|
||||||
startup: application
|
startup: application
|
||||||
ingress: true
|
ingress: true
|
||||||
@@ -32,8 +34,10 @@ options:
|
|||||||
gpu_layers: 0
|
gpu_layers: 0
|
||||||
debug: false
|
debug: false
|
||||||
models_path: "/share/localai/models"
|
models_path: "/share/localai/models"
|
||||||
|
threads: 8
|
||||||
schema:
|
schema:
|
||||||
master_token: str
|
master_token: str
|
||||||
gpu_layers: "int(0,)"
|
gpu_layers: "int(0,)"
|
||||||
debug: "bool?"
|
debug: "bool?"
|
||||||
models_path: "str?"
|
models_path: "str?"
|
||||||
|
threads: "int(1,)"
|
||||||
|
|||||||
@@ -1,51 +1,37 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/with-contenv bashio
|
||||||
|
|
||||||
# Forcer l'utilisation de la configuration Home Assistant
|
# Les variables d'environnement sont automatiquement disponibles depuis les options
|
||||||
echo "Using Home Assistant configuration"
|
echo "Starting LocalAI P2P Worker"
|
||||||
|
echo "Master Token: $(bashio::config 'master_token')"
|
||||||
|
echo "GPU Layers: $(bashio::config 'gpu_layers')"
|
||||||
|
echo "Models Path: $(bashio::config 'models_path')"
|
||||||
|
|
||||||
# Vérifier que bashio est disponible
|
# Configurer le token P2P si fourni
|
||||||
if [ -f /usr/bin/bashio ]; then
|
TOKEN="$(bashio::config 'master_token')"
|
||||||
echo "DEBUG: bashio found, reading configuration"
|
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ]; then
|
||||||
GPU_LAYERS="$(bashio config gpu_layers 2>/dev/null || echo '0')"
|
|
||||||
TOKEN="$(bashio config master_token 2>/dev/null || echo '')"
|
|
||||||
MODELS_PATH="$(bashio config models_path 2>/dev/null || echo '/share/localai/models')"
|
|
||||||
else
|
|
||||||
echo "DEBUG: bashio not found, using defaults"
|
|
||||||
GPU_LAYERS="0"
|
|
||||||
TOKEN=""
|
|
||||||
MODELS_PATH="/share/localai/models"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "DEBUG: GPU_LAYERS=$GPU_LAYERS"
|
|
||||||
echo "DEBUG: TOKEN from config: '$TOKEN'"
|
|
||||||
echo "DEBUG: MODELS_PATH=$MODELS_PATH"
|
|
||||||
|
|
||||||
# Forcer l'utilisation du token si fourni
|
|
||||||
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then
|
|
||||||
echo "DEBUG: Setting LOCALAI_P2P_TOKEN to: $TOKEN"
|
|
||||||
export LOCALAI_P2P_TOKEN="$TOKEN"
|
export LOCALAI_P2P_TOKEN="$TOKEN"
|
||||||
export P2P_TOKEN="$TOKEN"
|
export P2P_TOKEN="$TOKEN"
|
||||||
|
echo "P2P Token configured"
|
||||||
else
|
else
|
||||||
echo "DEBUG: No valid token provided in configuration"
|
echo "No P2P token provided - will generate one"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "DEBUG: LOCALAI_P2P_TOKEN is set to: '$LOCALAI_P2P_TOKEN'"
|
# Créer le répertoire des modèles
|
||||||
echo "DEBUG: P2P_TOKEN is set to: '$P2P_TOKEN'"
|
MODELS_PATH="$(bashio::config 'models_path')"
|
||||||
|
|
||||||
# Créer le répertoire des modèles s'il n'existe pas
|
|
||||||
mkdir -p "$MODELS_PATH"
|
mkdir -p "$MODELS_PATH"
|
||||||
|
|
||||||
# Nettoyer les fichiers de configuration corrompus
|
# Nettoyer les fichiers corrompus
|
||||||
echo "DEBUG: Cleaning corrupted config files in $MODELS_PATH"
|
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; 2>/dev/null | xargs rm -f 2>/dev/null || true
|
||||||
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; | while read file; do
|
|
||||||
echo "DEBUG: Removing corrupted file: $file"
|
|
||||||
rm -f "$file"
|
|
||||||
done 2>/dev/null || true
|
|
||||||
|
|
||||||
# Définir les variables d'environnement pour LocalAI
|
# Configurer les threads
|
||||||
export THREADS="${THREADS:-8}"
|
export THREADS="$(bashio::config 'threads' || echo '8')"
|
||||||
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-8}"
|
export OMP_NUM_THREADS="$THREADS"
|
||||||
|
|
||||||
# Lancer LocalAI avec nos paramètres
|
# Lancer LocalAI
|
||||||
echo "DEBUG: Starting LocalAI with models-path=$MODELS_PATH, threads=$THREADS"
|
echo "Starting LocalAI with models path: $MODELS_PATH"
|
||||||
exec /build/local-ai run --models-path="$MODELS_PATH" --threads="$THREADS" --address="0.0.0.0:8080" --cors --cors-allow-origins="*"
|
exec /usr/local/bin/local-ai run \
|
||||||
|
--models-path="$MODELS_PATH" \
|
||||||
|
--threads="$THREADS" \
|
||||||
|
--address="0.0.0.0:8080" \
|
||||||
|
--cors \
|
||||||
|
--cors-allow-origins="*"
|
||||||
|
|||||||
Reference in New Issue
Block a user