fox/Makefile

130 lines
4.0 KiB
Makefile

SHELL := /bin/bash
DC := docker compose
APP := $(DC) exec app
APP_RUN := $(DC) run --rm app
OLLAMA_MODEL ?= llama3.1:8b
EMBED_MODEL ?= nomic-embed-text
.PHONY: help install up down restart shell logs ps build pull rebuild \
composer migrate seed fresh tinker queue-restart npm-build npm-dev \
ollama-pull whisper-model piper-voice
help:
@echo "Fox - Make targets:"
@echo " make install - First-time setup: build, vendor, key, migrate, models"
@echo " make up - Start all containers"
@echo " make down - Stop all containers"
@echo " make restart - Restart everything"
@echo " make shell - Open shell in app container"
@echo " make logs - Tail container logs"
@echo " make ps - List containers"
@echo " make build - (Re)build images"
@echo " make rebuild - Force rebuild without cache"
@echo " make migrate - Run database migrations"
@echo " make fresh - Reset DB and migrate from scratch"
@echo " make tinker - Open Tinker REPL"
@echo " make ollama-pull - Pull the configured Ollama model"
@echo " make whisper-model - Download whisper.cpp ggml model"
@echo " make piper-voice - Download piper TTS voice (de_DE-thorsten-medium)"
@echo " make npm-build - Build frontend assets"
@echo " make npm-dev - Run Vite in dev mode"
install:
@if [ ! -f .env ]; then cp .env.example .env; echo ".env erstellt aus .env.example"; fi
$(DC) build
$(DC) up -d postgres redis ollama
@echo "Warte auf Postgres..."
@until $(DC) exec -T postgres pg_isready -U fox >/dev/null 2>&1; do sleep 1; done
$(APP_RUN) composer install --no-interaction --prefer-dist --optimize-autoloader
$(APP_RUN) php artisan key:generate --force
$(APP_RUN) php artisan storage:link || true
$(APP_RUN) php artisan migrate --force
$(MAKE) ollama-pull
$(MAKE) whisper-model
$(MAKE) piper-voice
$(APP_RUN) sh -c 'command -v node >/dev/null 2>&1 || (apt-get update && apt-get install -y --no-install-recommends nodejs npm)'
$(APP_RUN) npm install
$(APP_RUN) npm run build
$(DC) up -d
@echo ""
@echo "Fox ist erreichbar unter http://10.10.90.175"
@echo "Reverb (WebSocket) auf Port 8080"
up:
$(DC) up -d
down:
$(DC) down
restart: down up
shell:
$(APP) bash
logs:
$(DC) logs -f --tail=100
ps:
$(DC) ps
build:
$(DC) build
rebuild:
$(DC) build --no-cache
composer:
$(APP_RUN) composer $(filter-out $@,$(MAKECMDGOALS))
migrate:
$(APP_RUN) php artisan migrate
fresh:
$(APP_RUN) php artisan migrate:fresh --force
tinker:
$(APP) php artisan tinker
queue-restart:
$(APP) php artisan queue:restart
npm-build:
$(DC) run --rm vite npm run build
@$(DC) exec -T --user root app rm -f public/hot 2>/dev/null || true
@$(DC) exec -T --user root app sh -c 'chown -R www-data:www-data public/build 2>/dev/null || true'
@echo "Production-Assets gebaut, public/hot entfernt."
# Wechsel auf Production-Build: Vite stoppen + frisch builden + hot-File weg.
prod: npm-dev-stop npm-build
npm-dev:
$(DC) --profile dev up vite
npm-dev-stop:
@$(DC) --profile dev stop vite 2>/dev/null || true
@$(DC) exec -T --user root app rm -f public/hot 2>/dev/null || true
@echo "Vite gestoppt, public/hot entfernt - Production-Build ist aktiv."
ollama-pull:
@echo "Pulle Ollama-Modell $(OLLAMA_MODEL)..."
$(DC) exec -T ollama ollama pull $(OLLAMA_MODEL)
@echo "Pulle Embedding-Modell $(EMBED_MODEL)..."
$(DC) exec -T ollama ollama pull $(EMBED_MODEL)
whisper-model:
@echo "Lade whisper.cpp ggml-base Modell..."
$(DC) exec -T whisper sh -c 'cd /models && [ -f ggml-base.bin ] || wget -q https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin'
piper-voice:
mkdir -p storage/app/voices
wget -q -O storage/app/voices/de_DE-thorsten-medium.onnx \
https://huggingface.co/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten/medium/de_DE-thorsten-medium.onnx
wget -q -O storage/app/voices/de_DE-thorsten-medium.onnx.json \
https://huggingface.co/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten/medium/de_DE-thorsten-medium.onnx.json
@echo "Piper Voice heruntergeladen."
%:
@: