44
Some checks failed
Builder / Build addons (localai-p2p-master, amd64) (push) Failing after 9s
Builder / Build addons (localai-p2p-worker, amd64) (push) Failing after 8s
Validate / validate (push) Failing after 2s
Builder / Create release (push) Has been skipped

This commit is contained in:
2025-05-30 15:39:05 +02:00
parent cbf28e0b54
commit 3af6d60f57
5 changed files with 75 additions and 56 deletions

View File

@@ -1,12 +1,18 @@
FROM ghcr.io/hassio-addons/base:15.0.7
FROM localai/localai:latest-cpu
# 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
# Installer bashio pour Home Assistant
RUN apt-get update && \
apt-get install -y --no-install-recommends \
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/*
# Variables d'environnement pour LocalAI
ENV LOCALAI_P2P="true"
@@ -16,14 +22,8 @@ ENV LOCALAI_ADDRESS="0.0.0.0:8080"
ENV LOCALAI_CORS="true"
ENV LOCALAI_CORS_ALLOW_ORIGINS="*"
# Copier le script de démarrage pour s6-overlay
RUN mkdir -p /etc/services.d/localai
COPY run.sh /etc/services.d/localai/run
RUN chmod +x /etc/services.d/localai/run
# Copier le script de démarrage
COPY run.sh /usr/bin/run.sh
RUN chmod +x /usr/bin/run.sh
# Créer un entrypoint qui utilise exec /init
RUN echo '#!/bin/bash' > /entrypoint.sh && \
echo 'exec /init' >> /entrypoint.sh && \
chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/usr/bin/run.sh"]

View File

@@ -1,25 +1,34 @@
#!/usr/bin/with-contenv bashio
#!/bin/bash
# Les variables d'environnement sont automatiquement disponibles depuis les options
echo "Starting LocalAI P2P Master"
echo "GPU Layers: $(bashio::config 'gpu_layers')"
echo "Models Path: $(bashio::config 'models_path')"
# Lire la configuration Home Assistant
if [ -f /data/options.json ]; then
MODELS_PATH="$(bashio::config 'models_path' 2>/dev/null || echo '/share/localai/models')"
THREADS="$(bashio::config 'threads' 2>/dev/null || echo '8')"
echo "Models Path: $MODELS_PATH"
echo "Threads: $THREADS"
else
echo "No Home Assistant config found, using defaults"
MODELS_PATH="/share/localai/models"
THREADS="8"
fi
# Créer le répertoire des modèles
MODELS_PATH="$(bashio::config 'models_path')"
mkdir -p "$MODELS_PATH"
# Nettoyer les fichiers corrompus
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
# Configurer les threads
export THREADS="$(bashio::config 'threads' || echo '8')"
# Configurer les variables d'environnement
export THREADS="$THREADS"
export OMP_NUM_THREADS="$THREADS"
# Lancer LocalAI (master génère automatiquement un token)
echo "Starting LocalAI Master with models path: $MODELS_PATH"
echo "P2P Token will be generated automatically"
exec /usr/local/bin/local-ai run \
exec /build/local-ai run \
--models-path="$MODELS_PATH" \
--threads="$THREADS" \
--address="0.0.0.0:8080" \