Add self-deploying setup scripts for all sub-projects (P1-P8)

- Root setup.sh orchestrator with per-phase dispatch (./setup.sh p1..p8 | all | status)
- Makefile convenience targets (make infra, make llm, make status, etc.)
- scripts/common.sh: shared bash library for OS detection, Docker helpers,
  service management (launchd/systemd), package install, env management
- .env.example + .gitignore: shared config template and secret exclusions

P1 (homeai-infra): full implementation
- docker-compose.yml: Uptime Kuma, code-server, n8n
- Note: Home Assistant, Portainer, Gitea are pre-existing instances
- setup.sh: Docker install, homeai network, container health checks

P2 (homeai-llm): full implementation
- Ollama native install with CUDA/ROCm/Metal auto-detection
- launchd plist (macOS) + systemd service (Linux) for auto-start
- scripts/pull-models.sh: idempotent model puller from manifest
- scripts/benchmark.sh: tokens/sec measurement per model
- Open WebUI on port 3030 (avoids Gitea :3000 conflict)

P3-P8: working stubs with prerequisite checks and TODO sections

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Aodhan Collins
2026-03-04 21:10:53 +00:00
parent 38247d7cc4
commit 7978eaea14
23 changed files with 2525 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
# homeai-infra Docker secrets
# Copy to .env — never commit .env
DATA_DIR=${HOME}/homeai-data
# ─── code-server ───────────────────────────────────────────────────────────────
CODE_SERVER_PASSWORD=changeme123
# ─── n8n ───────────────────────────────────────────────────────────────────────
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=changeme123
N8N_ENCRYPTION_KEY=changeme_random_32_char_string

View File

@@ -0,0 +1,91 @@
---
# homeai-infra/docker/docker-compose.yml
# P1 — Infrastructure services
#
# Provides: Uptime Kuma, code-server, n8n
#
# NOTE: Home Assistant, Portainer, and Gitea are pre-existing instances
# and are NOT managed here. Point .env.services at their existing URLs.
#
# Prerequisites:
# - Docker installed and running
# - `homeai` Docker network exists (created by setup.sh)
# - .env file present (copy from .env.example)
#
# Usage:
# docker compose -f docker/docker-compose.yml up -d
# docker compose -f docker/docker-compose.yml down
name: homeai-infra
# Linux compatibility: host.docker.internal:host-gateway resolves host IP
# On macOS this is already defined; on Linux it maps to the Docker bridge gateway.
x-host-gateway: &host-gateway
extra_hosts:
- "host.docker.internal:host-gateway"
services:
# ─── Uptime Kuma ─────────────────────────────────────────────────────────────
uptime-kuma:
container_name: homeai-uptime-kuma
image: louislam/uptime-kuma:latest
restart: unless-stopped
ports:
- "3001:3001"
volumes:
- ${DATA_DIR:-~/homeai-data}/uptime-kuma:/app/data
networks:
- homeai
labels:
- homeai.service=uptime-kuma
- homeai.url=http://localhost:3001
# ─── code-server (browser VS Code) ───────────────────────────────────────────
code-server:
container_name: homeai-code-server
image: codercom/code-server:latest
restart: unless-stopped
ports:
- "8090:8080" # Note: exposed on 8090 to avoid conflict with OpenClaw (8080)
volumes:
- ${DATA_DIR:-~/homeai-data}/code-server:/home/coder/.config
- ${HOME}:/home/coder/host:rw # Mount home dir for file access
environment:
- PASSWORD=${CODE_SERVER_PASSWORD:-changeme123}
<<: *host-gateway
networks:
- homeai
labels:
- homeai.service=code-server
- homeai.url=http://localhost:8090
# ─── n8n (workflow automation) ───────────────────────────────────────────────
n8n:
container_name: homeai-n8n
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
volumes:
- ${DATA_DIR:-~/homeai-data}/n8n:/home/node/.n8n
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER:-admin}
- N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD:-changeme123}
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY:-changeme}
- N8N_HOST=0.0.0.0
- N8N_PORT=5678
- N8N_PROTOCOL=http
- WEBHOOK_URL=http://localhost:5678/
<<: *host-gateway
networks:
- homeai
labels:
- homeai.service=n8n
- homeai.url=http://localhost:5678
networks:
homeai:
external: true
name: homeai

135
homeai-infra/setup.sh Normal file
View File

@@ -0,0 +1,135 @@
#!/usr/bin/env bash
# homeai-infra/setup.sh — P1: Infrastructure stack
#
# Installs Docker (if needed), creates the homeai network,
# and starts new infrastructure services.
#
# Services started:
# Uptime Kuma :3001
# code-server :8090
# n8n :5678
#
# NOTE: Home Assistant, Portainer, and Gitea are pre-existing instances.
# Set their URLs in ~/.env.services manually.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
# shellcheck source=../scripts/common.sh
source "${REPO_DIR}/scripts/common.sh"
COMPOSE_FILE="${SCRIPT_DIR}/docker/docker-compose.yml"
ENV_FILE="${SCRIPT_DIR}/docker/.env"
ENV_EXAMPLE="${SCRIPT_DIR}/docker/.env.example"
# ─── Pre-flight ────────────────────────────────────────────────────────────────
preflight() {
log_section "P1 Preflight"
detect_platform
# Ensure .env exists
if [[ ! -f "$ENV_FILE" ]]; then
if [[ -f "$ENV_EXAMPLE" ]]; then
cp "$ENV_EXAMPLE" "$ENV_FILE"
log_warn "Created ${ENV_FILE} from .env.example"
log_warn "Edit it now with real secrets, then re-run this script."
echo ""
echo " Secrets to set in ${ENV_FILE}:"
echo " CODE_SERVER_PASSWORD — your password"
echo " N8N_BASIC_AUTH_PASSWORD — your password"
echo " N8N_ENCRYPTION_KEY — 32-char random string (run: openssl rand -hex 16)"
echo ""
if ! confirm "Secrets are still at defaults. Continue anyway? (not safe for production)"; then
log_info "Aborting. Fill in ${ENV_FILE} and re-run."
exit 0
fi
else
die "No .env or .env.example found at ${SCRIPT_DIR}/docker/"
fi
fi
# Create data directory
local data_dir
load_env "$ENV_FILE"
data_dir="${DATA_DIR:-${HOME}/homeai-data}"
log_step "Data directory: ${data_dir}"
mkdir -p \
"${data_dir}/uptime-kuma" \
"${data_dir}/code-server" \
"${data_dir}/n8n"
log_success "Data directories ready."
}
# ─── Docker ────────────────────────────────────────────────────────────────────
setup_docker() {
log_section "Docker"
install_docker
ensure_docker_running
ensure_docker_network homeai
}
# ─── Services ──────────────────────────────────────────────────────────────────
start_services() {
log_section "Starting infra services"
log_step "Pulling latest images..."
docker_compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" pull
log_step "Starting containers..."
docker_compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d
log_success "Containers started."
}
# ─── Health checks ─────────────────────────────────────────────────────────────
health_check() {
log_section "Health checks"
wait_for_http "http://localhost:3001" "Uptime Kuma" 60
wait_for_http "http://localhost:5678" "n8n" 90
wait_for_http "http://localhost:8090" "code-server" 60
}
# ─── Register services ─────────────────────────────────────────────────────────
register_services() {
log_section "Writing service URLs"
write_env_service "UPTIME_KUMA_URL" "http://localhost:3001"
write_env_service "CODE_SERVER_URL" "http://localhost:8090"
write_env_service "N8N_URL" "http://localhost:5678"
log_warn "Set these in ~/.env.services manually (pre-existing instances):"
log_warn " HA_URL, HA_TOKEN, PORTAINER_URL, GITEA_URL"
log_success "Service URLs written to ~/.env.services"
}
# ─── Summary ───────────────────────────────────────────────────────────────────
print_infra_summary() {
print_summary "P1 Infrastructure — Ready" \
"Uptime Kuma" "http://localhost:3001" \
"code-server" "http://localhost:8090" \
"n8n" "http://localhost:5678"
echo " Pre-existing services (not managed here):"
echo " Home Assistant, Portainer, Gitea"
echo ""
echo " Next steps:"
echo " 1. Add HA_URL, HA_TOKEN, PORTAINER_URL, GITEA_URL to ~/.env.services"
echo " 2. Add Uptime Kuma monitors for all HomeAI services"
echo " 3. Run: ./setup.sh p2 (Ollama + LLM)"
echo ""
}
# ─── Main ──────────────────────────────────────────────────────────────────────
main() {
preflight
setup_docker
start_services
health_check
register_services
print_infra_summary
}
main "$@"