Files
buchwerk/Makefile
2026-09-30 00:59:44 +02:00

60 lines
2.3 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.PHONY: install build run dev auth prod stop logs push pull loeschen
PY := .venv/bin/python
COMPOSE = docker compose
SERVER ?= root@178.104.67.87
URL ?= https://buchwerk.marha.de
REMOTE ?= /var/www/buchwerk
# Themen zwischen lokal und Server abgleichen; TOPIC=<Name> beschränkt auf ein Thema.
# Ausgeschlossen: Arbeitsdateien der Agenten (arbeit/) und Logs. Ohne --delete: nichts wird entfernt.
SYNC_QUELLE = storage/$(if $(TOPIC),$(TOPIC)/,)
SYNC_AUS = --exclude 'arbeit/' --exclude '*.log' --exclude '*.tmp'
install:
python3 -m venv .venv
.venv/bin/pip install -r backend/requirements.txt
cd frontend && npm install
build:
cd frontend && npm run build
run:
$(PY) -m uvicorn backend.main:app --port 8020
dev:
$(PY) -m uvicorn backend.main:app --reload --port 8020 & cd frontend && npm run dev
auth:
@mkdir -p .claude-data storage
@chown -R 1000:1000 .claude-data storage 2>/dev/null || sudo chown -R 1000:1000 .claude-data storage
@grep -q "^CLAUDE_CODE_OAUTH_TOKEN=.\+" .env 2>/dev/null || grep -q "^ANTHROPIC_API_KEY=.\+" .env 2>/dev/null \
|| echo "WARNUNG: weder CLAUDE_CODE_OAUTH_TOKEN noch ANTHROPIC_API_KEY in .env – Agenten können nicht starten (Token: claude setup-token)."
prod: auth
$(COMPOSE) up -d --build
@echo "buchwerk läuft: https://buchwerk.marha.de"
stop:
$(COMPOSE) down
logs:
$(COMPOSE) logs -f --tail=200
push:
@[ -z "$(TOPIC)" ] || [ -d "storage/$(TOPIC)" ] || { echo "storage/$(TOPIC) fehlt"; exit 1; }
rsync -az --progress --mkpath --chown=1000:1000 $(SYNC_AUS) "$(SYNC_QUELLE)" "$(SERVER):$(REMOTE)/$(SYNC_QUELLE)"
@echo "Hochgeladen: $(SYNC_QUELLE) → $(SERVER):$(REMOTE)"
pull:
rsync -az --progress --mkpath $(SYNC_AUS) "$(SERVER):$(REMOTE)/$(SYNC_QUELLE)" "$(SYNC_QUELLE)"
@echo "Geholt: $(SERVER):$(REMOTE)/$(SYNC_QUELLE) → $(SYNC_QUELLE)"
# Fertige Bücher lassen sich in der Oberfläche nicht löschen. Nur hier, mit Rückfrage:
# make loeschen TOPIC="Godot 4" – entfernt das Thema auf dem Server (über die API) und lokal.
loeschen:
@[ -n "$(TOPIC)" ] || { echo "TOPIC=<Name> angeben"; exit 1; }
@printf 'Thema „%s“ samt Buch auf dem Server und lokal unwiderruflich löschen? [j/N] ' "$(TOPIC)"; read a; [ "$$a" = "j" ]
curl -fsS -X DELETE "$(URL)/api/topics/$$(python3 -c 'import sys,urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$(TOPIC)")" && echo
rm -rf "storage/$(TOPIC)"
@echo "Gelöscht: $(TOPIC)"