diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c299a87 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 + +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libgomp1 libgl1 ffmpeg curl python3 ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +COPY local-ai /usr/local/bin/local-ai + +ENV MODEL_PATH=/models +ENV CONFIG_PATH=/config +ENV ENABLE_BACKENDS=llama-cuda,whispercpp,stablediffusion,ollama +ENV AUTOLOAD_MODELS=true +ENV INCLUDE_DEFAULT_MODELS=true + +VOLUME /models +VOLUME /config + +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD curl -f http://localhost:8080/readyz || exit 1 + +EXPOSE 8080 + +CMD ["/usr/local/bin/local-ai"] + diff --git a/setup-ai-stack.sh b/setup-ai-stack.sh index b177b8f..ba4378a 100644 --- a/setup-ai-stack.sh +++ b/setup-ai-stack.sh @@ -44,30 +44,55 @@ if [[ "$1" == "--update" ]]; then echo "⚠️ JupyterLab is not running, skipping update." fi +# --- LocalAI custom build and update --- +LOCALAI_REPO=~/git-repos/LocalAI +DOCKERFILE_URL="https://your-domain.com/path/to/Dockerfile" - # 🔁 Updating LocalAI (GPU build) - if check_container_running "localai"; then - echo "🧠 Updating LocalAI..." - docker stop localai - docker rm localai - else - echo "➕ Installing LocalAI..." - fi +echo "🔁 Rebuilding LocalAI (custom)..." - docker pull localai/localai:latest-aio-gpu-nvidia-cuda-12 +# Backup and remove existing repo +if [ -d "$LOCALAI_REPO" ]; then + echo "📦 Backing up existing LocalAI repo..." + mv "$LOCALAI_REPO" "${LOCALAI_REPO}_backup_$(date +%s)" +fi - # Ensure default models.yaml exists - MODELS_YAML=~/ai-stack/localai/config/models.yaml - if [ ! -f "$MODELS_YAML" ]; then - echo "📄 Creating default models.yaml..." -cat > "$MODELS_YAML" </dev/null || true +docker rm localai 2>/dev/null || true + +# Create model and config directories if needed +mkdir -p ~/ai-stack/localai/models +mkdir -p ~/ai-stack/localai/config + +# Run new container docker run -d \ --name localai \ --gpus all \ @@ -79,9 +104,48 @@ docker run -d \ -e AUTOLOAD_MODELS=true \ -e MODEL_PATH=/models \ --restart unless-stopped \ - localai/localai:latest-aio-gpu-nvidia-cuda-12 + localai:custom -echo "✅ LocalAI running at http://localhost:8080" +echo "✅ LocalAI (custom) is now running at http://localhost:8080" + + +# # 🔁 Updating LocalAI (GPU build) +# if check_container_running "localai"; then +# echo "🧠 Updating LocalAI..." +# docker stop localai +# docker rm localai +# else +# echo "➕ Installing LocalAI..." +# fi + +# docker pull localai/localai:latest-aio-gpu-nvidia-cuda-12 + +# # Ensure default models.yaml exists +# MODELS_YAML=~/ai-stack/localai/config/models.yaml +# if [ ! -f "$MODELS_YAML" ]; then +# echo "📄 Creating default models.yaml..." +# cat > "$MODELS_YAML" < ~/ai-stack/localai/config/models.yaml <