diff --git a/localai-p2p-master/Dockerfile b/localai-p2p-master/Dockerfile index f46e09d..2361254 100644 --- a/localai-p2p-master/Dockerfile +++ b/localai-p2p-master/Dockerfile @@ -6,5 +6,8 @@ ENV LOCALAI_P2P="true" ENV LOCALAI_FEDERATED="true" -COPY run.sh /build/entrypoint.sh -RUN chmod +x /build/entrypoint.sh +COPY run.sh /build/custom-entrypoint.sh +RUN chmod +x /build/custom-entrypoint.sh + +# Remplacer l'entrypoint par défaut +ENTRYPOINT ["/build/custom-entrypoint.sh"] diff --git a/localai-p2p-master/run.sh b/localai-p2p-master/run.sh index 96c773c..9ccb89b 100644 --- a/localai-p2p-master/run.sh +++ b/localai-p2p-master/run.sh @@ -1,9 +1,17 @@ -#!/usr/bin/with-contenv bashio -CONFIG_PATH=/data/options.json +#!/bin/bash -GPU_LAYERS="$(bashio::config 'gpu_layers')" -TOKEN="$(bashio::config 'master_token')" -MODELS_PATH="$(bashio::config 'models_path')" +# Configuration par défaut si bashio n'est pas disponible +if command -v bashio >/dev/null 2>&1; then + echo "Using Home Assistant configuration" + GPU_LAYERS="$(bashio::config 'gpu_layers')" + TOKEN="$(bashio::config 'master_token')" + MODELS_PATH="$(bashio::config 'models_path')" +else + echo "Using environment variables" + GPU_LAYERS="${GPU_LAYERS:-99}" + TOKEN="${LOCALAI_P2P_TOKEN:-}" + MODELS_PATH="${LOCALAI_MODELS_PATH:-/share/localai/models}" +fi echo "DEBUG: GPU_LAYERS=$GPU_LAYERS" echo "DEBUG: TOKEN from config: '$TOKEN'" @@ -13,7 +21,6 @@ echo "DEBUG: MODELS_PATH=$MODELS_PATH" if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then echo "DEBUG: Setting LOCALAI_P2P_TOKEN to: $TOKEN" export LOCALAI_P2P_TOKEN="$TOKEN" - # Aussi définir la variable pour LocalAI export P2P_TOKEN="$TOKEN" else echo "DEBUG: No valid token provided in configuration" @@ -27,16 +34,11 @@ mkdir -p "$MODELS_PATH" # Nettoyer les fichiers de configuration corrompus echo "DEBUG: Cleaning corrupted config files in $MODELS_PATH" -# Supprimer les fichiers contenant du code shell -find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio" {} \; | while read file; do +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 -# Supprimer aussi les fichiers avec des erreurs de mapping YAML -find "$MODELS_PATH" -name "*.yaml" -exec grep -l "mapping values are not allowed in this context" {} \; | while read file; do - echo "DEBUG: Removing YAML mapping error file: $file" - rm -f "$file" -done 2>/dev/null || true - +# Lancer LocalAI avec nos paramètres +echo "DEBUG: Starting LocalAI with models-path=$MODELS_PATH, gpu-layers=$GPU_LAYERS" exec /build/local-ai run --models-path="$MODELS_PATH" --gpu-layers="$GPU_LAYERS" --address="0.0.0.0:8080" --cors --cors-allow-origins="*" diff --git a/localai-p2p-worker/Dockerfile b/localai-p2p-worker/Dockerfile index f46e09d..2361254 100644 --- a/localai-p2p-worker/Dockerfile +++ b/localai-p2p-worker/Dockerfile @@ -6,5 +6,8 @@ ENV LOCALAI_P2P="true" ENV LOCALAI_FEDERATED="true" -COPY run.sh /build/entrypoint.sh -RUN chmod +x /build/entrypoint.sh +COPY run.sh /build/custom-entrypoint.sh +RUN chmod +x /build/custom-entrypoint.sh + +# Remplacer l'entrypoint par défaut +ENTRYPOINT ["/build/custom-entrypoint.sh"] diff --git a/localai-p2p-worker/config.yaml b/localai-p2p-worker/config.yaml index 612b6e6..27e8875 100644 --- a/localai-p2p-worker/config.yaml +++ b/localai-p2p-worker/config.yaml @@ -1,5 +1,5 @@ name: "LocalAI P2P Worker" -version: "1.0.3.6" # Incrémentez aussi la version +version: "1.0.3.7" # Incrémentez aussi la version slug: "localai-p2p-worker" # ⬅️ IMPORTANT : doit correspondre au nom du dossier description: "LocalAI P2P federation worker node" arch: diff --git a/localai-p2p-worker/run.sh b/localai-p2p-worker/run.sh index 96c773c..b54f702 100644 --- a/localai-p2p-worker/run.sh +++ b/localai-p2p-worker/run.sh @@ -1,9 +1,17 @@ -#!/usr/bin/with-contenv bashio -CONFIG_PATH=/data/options.json +#!/bin/bash -GPU_LAYERS="$(bashio::config 'gpu_layers')" -TOKEN="$(bashio::config 'master_token')" -MODELS_PATH="$(bashio::config 'models_path')" +# Configuration par défaut si bashio n'est pas disponible +if command -v bashio >/dev/null 2>&1; then + echo "Using Home Assistant configuration" + GPU_LAYERS="$(bashio::config 'gpu_layers')" + TOKEN="$(bashio::config 'master_token')" + MODELS_PATH="$(bashio::config 'models_path')" +else + echo "Using environment variables" + GPU_LAYERS="${GPU_LAYERS:-0}" + TOKEN="${LOCALAI_P2P_TOKEN:-}" + MODELS_PATH="${LOCALAI_MODELS_PATH:-/share/localai/models}" +fi echo "DEBUG: GPU_LAYERS=$GPU_LAYERS" echo "DEBUG: TOKEN from config: '$TOKEN'" @@ -13,7 +21,6 @@ echo "DEBUG: MODELS_PATH=$MODELS_PATH" if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then echo "DEBUG: Setting LOCALAI_P2P_TOKEN to: $TOKEN" export LOCALAI_P2P_TOKEN="$TOKEN" - # Aussi définir la variable pour LocalAI export P2P_TOKEN="$TOKEN" else echo "DEBUG: No valid token provided in configuration" @@ -27,16 +34,11 @@ mkdir -p "$MODELS_PATH" # Nettoyer les fichiers de configuration corrompus echo "DEBUG: Cleaning corrupted config files in $MODELS_PATH" -# Supprimer les fichiers contenant du code shell -find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio" {} \; | while read file; do +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 -# Supprimer aussi les fichiers avec des erreurs de mapping YAML -find "$MODELS_PATH" -name "*.yaml" -exec grep -l "mapping values are not allowed in this context" {} \; | while read file; do - echo "DEBUG: Removing YAML mapping error file: $file" - rm -f "$file" -done 2>/dev/null || true - +# Lancer LocalAI avec nos paramètres +echo "DEBUG: Starting LocalAI with models-path=$MODELS_PATH, gpu-layers=$GPU_LAYERS" exec /build/local-ai run --models-path="$MODELS_PATH" --gpu-layers="$GPU_LAYERS" --address="0.0.0.0:8080" --cors --cors-allow-origins="*"