test
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:57:59 +02:00
parent 70e1bebf0d
commit 1364c3c492
24 changed files with 349 additions and 80 deletions

View File

@@ -0,0 +1,119 @@
ARG BUILD_FROM=ubuntu:noble
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
# Environment variables
ENV \
CARGO_NET_GIT_FETCH_WITH_CLI=true \
DEBIAN_FRONTEND="noninteractive" \
HOME="/root" \
LANG="C.UTF-8" \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PIP_PREFER_BINARY=1 \
PS1="$(whoami)@$(hostname):$(pwd)$ " \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_CMD_WAIT_FOR_SERVICES=1 \
YARN_HTTP_TIMEOUT=1000000 \
TERM="xterm-256color"
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install base system
ARG BUILD_ARCH=amd64
ARG BASHIO_VERSION="v0.17.0"
ARG S6_OVERLAY_VERSION="3.2.1.0"
ARG TEMPIO_VERSION="2024.11.2"
RUN \
apt-get update \
\
&& apt-get install -y --no-install-recommends \
ca-certificates=20240203 \
curl=8.5.0-2ubuntu10.6 \
jq=1.7.1-3build1 \
tzdata=2025b-0ubuntu0.24.04 \
xz-utils=5.6.1+really5.4.5-1 \
\
&& S6_ARCH="${BUILD_ARCH}" \
&& if [ "${BUILD_ARCH}" = "i386" ]; then S6_ARCH="i686"; \
elif [ "${BUILD_ARCH}" = "amd64" ]; then S6_ARCH="x86_64"; \
elif [ "${BUILD_ARCH}" = "armv7" ]; then S6_ARCH="arm"; fi \
\
&& curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" \
| tar -C / -Jxpf - \
\
&& curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz" \
| tar -C / -Jxpf - \
\
&& curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz" \
| tar -C / -Jxpf - \
\
&& curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz" \
| tar -C / -Jxpf - \
\
&& mkdir -p /etc/fix-attrs.d \
&& mkdir -p /etc/services.d \
\
&& curl -J -L -o /tmp/bashio.tar.gz \
"https://github.com/hassio-addons/bashio/archive/${BASHIO_VERSION}.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 \
\
&& curl -L -s -o /usr/bin/tempio \
"https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" \
&& chmod a+x /usr/bin/tempio \
\
&& apt-get purge -y --auto-remove \
xz-utils \
&& apt-get clean \
&& rm -fr \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
# Copy root filesystem
COPY rootfs /
# Copy s6-overlay adjustments
COPY s6-overlay /package/admin/s6-overlay-${S6_OVERLAY_VERSION}/
# Entrypoint & CMD
ENTRYPOINT [ "/init" ]
# Build arugments
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
ARG BUILD_REPOSITORY
# Labels
LABEL \
io.hass.name="Addon Ubuntu base for ${BUILD_ARCH}" \
io.hass.description="Home Assistant Community Add-on: ${BUILD_ARCH} Ubuntu base image" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="base" \
io.hass.version=${BUILD_VERSION} \
io.hass.base.version=${BUILD_VERSION} \
io.hass.base.name="ubuntu" \
io.hass.base.image="hassioaddons/ubuntu-base" \
maintainer="Franck Nijhof <frenck@addons.community>" \
org.opencontainers.image.title="Addon Ubuntu base for ${BUILD_ARCH}" \
org.opencontainers.image.description="Home Assistant Community Add-on: ${BUILD_ARCH} Ubuntu base image" \
org.opencontainers.image.vendor="Home Assistant Community Add-ons" \
org.opencontainers.image.authors="Franck Nijhof <frenck@addons.community>" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://addons.community" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

View File

@@ -0,0 +1,7 @@
---
build_from:
aarch64: arm64v8/ubuntu:noble
amd64: amd64/ubuntu:noble
armv7: arm32v7/ubuntu:noble
codenotary:
signer: codenotary@frenck.dev

View File

@@ -0,0 +1,10 @@
---
name: Ubuntu Base Image
version: dev
slug: ubuntu-base
description: Docker Ubuntu base images used by Home Assistant Community Add-ons.
url: https://github.com/hassio-addons/addon-ubuntu-base
arch:
- aarch64
- amd64
- armv7

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ==============================================================================
# Home Assistant Community Add-on: Base Images
# This script patches all service commands into the appropriate s6- commands
# Why not systemd? Docker said no, so did we ;)
# ==============================================================================
start() {
s6-svc -wU -u -T2500 "/run/service/${service}"
}
stop() {
s6-svc -wD -d -T2500 "/run/service/${service}"
}
restart() {
stop
start
}
status() {
s6-svstat "/run/service/${service}"
}
service="$1"
command="$2"
if [[ ! -d "/run/service/${service}" ]] ; then
echo "s6 service not found for ${service}, exiting..."
exit
fi;
${command} "${service}"

View File

@@ -0,0 +1,38 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Base Images
# Displays a simple add-on banner on startup
# ==============================================================================
if bashio::supervisor.ping; then
bashio::log.blue \
'-----------------------------------------------------------'
bashio::log.blue " Add-on: $(bashio::addon.name)"
bashio::log.blue " $(bashio::addon.description)"
bashio::log.blue \
'-----------------------------------------------------------'
bashio::log.blue " Add-on version: $(bashio::addon.version)"
if bashio::var.true "$(bashio::addon.update_available)"; then
bashio::log.magenta ' There is an update available for this add-on!'
bashio::log.magenta \
" Latest add-on version: $(bashio::addon.version_latest)"
bashio::log.magenta ' Please consider upgrading as soon as possible.'
else
bashio::log.green ' You are running the latest version of this add-on.'
fi
bashio::log.blue " System: $(bashio::info.operating_system)" \
" ($(bashio::info.arch) / $(bashio::info.machine))"
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
bashio::log.blue \
'-----------------------------------------------------------'
bashio::log.blue \
' Please, share the above information when looking for help'
bashio::log.blue \
' or support in, e.g., GitHub, forums or the Discord chat.'
bashio::log.blue \
'-----------------------------------------------------------'
fi

View File

@@ -0,0 +1,49 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Base Images
# Sets the log level correctly
# ==============================================================================
declare log_level
# Check if the log level configuration option exists
if bashio::config.exists log_level; then
# Find the matching LOG_LEVEL
log_level=$(bashio::string.lower "$(bashio::config log_level)")
case "${log_level}" in
all)
log_level="${__BASHIO_LOG_LEVEL_ALL}"
;;
trace)
log_level="${__BASHIO_LOG_LEVEL_TRACE}"
;;
debug)
log_level="${__BASHIO_LOG_LEVEL_DEBUG}"
;;
info)
log_level="${__BASHIO_LOG_LEVEL_INFO}"
;;
notice)
log_level="${__BASHIO_LOG_LEVEL_NOTICE}"
;;
warning)
log_level="${__BASHIO_LOG_LEVEL_WARNING}"
;;
error)
log_level="${__BASHIO_LOG_LEVEL_ERROR}"
;;
fatal)
log_level="${__BASHIO_LOG_LEVEL_FATAL}"
;;
off)
log_level="${__BASHIO_LOG_LEVEL_OFF}"
;;
*)
bashio::exit.nok "Unknown log_level: ${log_level}"
esac
# Save determined log level so S6 can pick it up later
echo "${log_level}" > /var/run/s6/container_environment/LOG_LEVEL
bashio::log.blue "Log level is set to ${__BASHIO_LOG_LEVELS[$log_level]}"
fi

View File

@@ -0,0 +1,12 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Base Images
# Configures the timezone
# ==============================================================================
bashio::log.info "Configuring timezone (${TZ:-None})..."
ln --symbolic --no-dereference --force "/usr/share/zoneinfo/${TZ:-UTC}" /etc/localtime
echo "${TZ:-UTC}" > /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata 2> /dev/null

View File

@@ -0,0 +1 @@
oneshot

View File

@@ -0,0 +1 @@
/package/admin/s6-overlay/etc/s6-rc/scripts/base-addon-banner

View File

@@ -0,0 +1 @@
oneshot

View File

@@ -0,0 +1 @@
/package/admin/s6-overlay/etc/s6-rc/scripts/base-addon-log-level

View File

@@ -0,0 +1 @@
oneshot

View File

@@ -0,0 +1 @@
/package/admin/s6-overlay/etc/s6-rc/scripts/base-addon-timezone

View File

@@ -1,16 +1,17 @@
FROM localai/localai:latest-cpu
# Utiliser la base Ubuntu Home Assistant
ARG BUILD_FROM=ghcr.io/hassio-addons/ubuntu-base:9.0.1
FROM ${BUILD_FROM}
# Installer bashio pour Home Assistant
# Installer LocalAI
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* && \
wget \
ca-certificates && \
wget -O /tmp/localai.tar.gz \
"https://github.com/mudler/LocalAI/releases/download/v2.22.1/local-ai-Linux-x86_64.tar.gz" && \
tar -xzf /tmp/localai.tar.gz -C /usr/local/bin/ && \
chmod +x /usr/local/bin/local-ai && \
rm /tmp/localai.tar.gz && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
@@ -22,8 +23,29 @@ ENV LOCALAI_ADDRESS="0.0.0.0:8080"
ENV LOCALAI_CORS="true"
ENV LOCALAI_CORS_ALLOW_ORIGINS="*"
# Copier le script de démarrage
COPY run.sh /usr/bin/run.sh
RUN chmod +x /usr/bin/run.sh
# Cer le service s6 pour LocalAI
RUN mkdir -p /etc/services.d/localai
COPY run.sh /etc/services.d/localai/run
RUN chmod +x /etc/services.d/localai/run
ENTRYPOINT ["/usr/bin/run.sh"]
# Build arguments
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="LocalAI P2P Worker" \
io.hass.description="LocalAI P2P federation worker node" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Alex <alex@example.com>" \
org.opencontainers.image.title="LocalAI P2P Worker" \
org.opencontainers.image.description="LocalAI P2P federation worker node" \
org.opencontainers.image.vendor="LocalAI Community" \
org.opencontainers.image.authors="Alex <alex@example.com>" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

View File

@@ -1,5 +1,5 @@
name: "LocalAI P2P Worker"
version: "1.0.4.6"
version: "1.0.4.7"
slug: "localai-p2p-worker"
description: "LocalAI P2P federation worker node"
arch:

View File

@@ -1,91 +1,64 @@
#!/bin/bash
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# LocalAI P2P Worker - Home Assistant Add-on
# ==============================================================================
# Initialiser bashio pour utiliser les fonctions de configuration Home Assistant
# shellcheck disable=SC1091
source /usr/lib/bashio/bashio || {
echo "Bashio not available, using direct JSON parsing"
BASHIO_AVAILABLE=false
}
echo "Starting LocalAI P2P Worker"
# Fonction pour lire la configuration avec fallback
get_config() {
local key="$1"
local default="$2"
if [ -f /data/options.json ]; then
if command -v bashio::config >/dev/null 2>&1; then
bashio::config "$key" 2>/dev/null || echo "$default"
else
# Fallback: utiliser jq pour lire directement le JSON
jq -r ".$key // \"$default\"" /data/options.json 2>/dev/null || echo "$default"
fi
else
echo "$default"
fi
}
bashio::log.info "Starting LocalAI P2P Worker"
# Lire la configuration Home Assistant
if [ -f /data/options.json ]; then
echo "Reading Home Assistant configuration..."
TOKEN="$(get_config 'master_token' '')"
GPU_LAYERS="$(get_config 'gpu_layers' '0')"
DEBUG="$(get_config 'debug' 'false')"
MODELS_PATH="$(get_config 'models_path' '/share/localai/models')"
THREADS="$(get_config 'threads' '8')"
echo "Master Token: $TOKEN"
echo "GPU Layers: $GPU_LAYERS"
echo "Debug: $DEBUG"
echo "Models Path: $MODELS_PATH"
echo "Threads: $THREADS"
else
echo "No Home Assistant config found, using defaults"
TOKEN=""
GPU_LAYERS="0"
DEBUG="false"
MODELS_PATH="/share/localai/models"
THREADS="8"
fi
TOKEN="$(bashio::config 'master_token')"
GPU_LAYERS="$(bashio::config 'gpu_layers')"
DEBUG="$(bashio::config 'debug')"
MODELS_PATH="$(bashio::config 'models_path')"
THREADS="$(bashio::config 'threads')"
bashio::log.info "Configuration loaded:"
bashio::log.info "- Master Token: ${TOKEN:0:20}..."
bashio::log.info "- GPU Layers: ${GPU_LAYERS}"
bashio::log.info "- Debug: ${DEBUG}"
bashio::log.info "- Models Path: ${MODELS_PATH}"
bashio::log.info "- Threads: ${THREADS}"
# Configurer le token P2P si fourni
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ] && [ "$TOKEN" != "" ]; then
export LOCALAI_P2P_TOKEN="$TOKEN"
export P2P_TOKEN="$TOKEN"
echo "P2P Token configured"
if bashio::var.has_value "${TOKEN}"; then
export LOCALAI_P2P_TOKEN="${TOKEN}"
export P2P_TOKEN="${TOKEN}"
bashio::log.info "P2P Token configured"
else
echo "No P2P token provided - will generate one"
bashio::log.warning "No P2P token provided - will generate one"
fi
# Créer le répertoire des modèles
mkdir -p "$MODELS_PATH"
bashio::log.info "Creating models directory: ${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
bashio::log.info "Cleaning corrupted files..."
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 variables d'environnement
export THREADS="$THREADS"
export OMP_NUM_THREADS="$THREADS"
export THREADS="${THREADS}"
export OMP_NUM_THREADS="${THREADS}"
# Configurer le debug si activé
if [ "$DEBUG" = "true" ]; then
if bashio::var.true "${DEBUG}"; then
export LOCALAI_DEBUG="true"
export LOCALAI_LOG_LEVEL="debug"
echo "Debug mode enabled"
bashio::log.info "Debug mode enabled"
fi
# Configurer GPU layers si spécifié
if [ "$GPU_LAYERS" -gt 0 ]; then
export LOCALAI_GPU_LAYERS="$GPU_LAYERS"
echo "GPU layers configured: $GPU_LAYERS"
if [ "${GPU_LAYERS}" -gt 0 ]; then
export LOCALAI_GPU_LAYERS="${GPU_LAYERS}"
bashio::log.info "GPU layers configured: ${GPU_LAYERS}"
fi
# Lancer LocalAI
echo "Starting LocalAI with models path: $MODELS_PATH"
exec /build/local-ai run \
--models-path="$MODELS_PATH" \
--threads="$THREADS" \
bashio::log.info "Starting LocalAI with models path: ${MODELS_PATH}"
exec /usr/local/bin/local-ai run \
--models-path="${MODELS_PATH}" \
--threads="${THREADS}" \
--address="0.0.0.0:8080" \
--cors \
--cors-allow-origins="*"