Makefile: deploy nutzt Layer-Cache, deploy-clean für erzwungenen Neuaufbau

This commit is contained in:
rene 2026-04-13 19:33:34 +02:00
parent d8b9561fff
commit f81c1e30bd

View file

@ -23,7 +23,7 @@ TAR_EXCLUDE := --exclude='.git' \
--exclude='./*.db' \ --exclude='./*.db' \
--exclude='./.DS_Store' --exclude='./.DS_Store'
.PHONY: help deploy sync push restart build stop status \ .PHONY: help deploy deploy-clean sync push restart build stop status \
logs logs-f shell db dev clean-cache check-ssh logs logs-f shell db dev clean-cache check-ssh
# ---------------------------------------------------------- # ----------------------------------------------------------
@ -47,7 +47,8 @@ help:
@echo "" @echo ""
@echo " Ban Yaro — verfügbare Befehle:" @echo " Ban Yaro — verfügbare Befehle:"
@echo "" @echo ""
@echo " make deploy Sync + Rebuild + Neustart (häufigster Befehl)" @echo " make deploy Sync + Rebuild + Neustart (mit Layer-Cache, häufigster Befehl)
make deploy-clean Wie deploy, aber --no-cache (bei requirements-Änderungen)"
@echo " make sync Nur Dateien zur DS übertragen (ohne Rebuild)" @echo " make sync Nur Dateien zur DS übertragen (ohne Rebuild)"
@echo " make push Nur Git push zu Forgejo (Backup/Versionierung)" @echo " make push Nur Git push zu Forgejo (Backup/Versionierung)"
@echo " make restart Container neustarten (kein Rebuild)" @echo " make restart Container neustarten (kein Rebuild)"
@ -75,7 +76,27 @@ deploy: check-ssh
@git push $(GIT_REMOTE) main @git push $(GIT_REMOTE) main
@echo "→ Sync zu DS..." @echo "→ Sync zu DS..."
@COPYFILE_DISABLE=1 tar czf - $(TAR_EXCLUDE) . | ssh $(DS_HOST) "tar xzf - -C $(DS_PATH)/" @COPYFILE_DISABLE=1 tar czf - $(TAR_EXCLUDE) . | ssh $(DS_HOST) "tar xzf - -C $(DS_PATH)/"
@echo "→ Docker rebuild + restart..." @echo "→ Docker rebuild + restart (mit Layer-Cache)..."
@ssh $(DS_HOST) " \
cd $(DS_PATH) && \
$(DOCKER) compose down && \
$(DOCKER) compose build && \
$(DOCKER) compose up -d"
@echo ""
@echo " ✓ Deploy fertig. Letzte Logs:"
@ssh $(DS_HOST) "$(DOCKER) logs $(CONTAINER) --tail=15"
# ----------------------------------------------------------
# DEPLOY-CLEAN — erzwingt Neuaufbau ohne Layer-Cache
# Nötig wenn: requirements.txt geändert, System-Pakete aktualisiert,
# oder nach einem kaputten Image-State
# ----------------------------------------------------------
deploy-clean: check-ssh
@echo "→ Git push (Backup)..."
@git push $(GIT_REMOTE) main
@echo "→ Sync zu DS..."
@COPYFILE_DISABLE=1 tar czf - $(TAR_EXCLUDE) . | ssh $(DS_HOST) "tar xzf - -C $(DS_PATH)/"
@echo "→ Docker rebuild (--no-cache) + restart..."
@ssh $(DS_HOST) " \ @ssh $(DS_HOST) " \
cd $(DS_PATH) && \ cd $(DS_PATH) && \
$(DOCKER) compose down && \ $(DOCKER) compose down && \
@ -113,12 +134,12 @@ restart: check-ssh
@echo " ✓ Neugestartet." @echo " ✓ Neugestartet."
# ---------------------------------------------------------- # ----------------------------------------------------------
# BUILD — nur Docker-Image neu bauen # BUILD — nur Docker-Image neu bauen (mit Layer-Cache)
# ---------------------------------------------------------- # ----------------------------------------------------------
build: check-ssh build: check-ssh
@ssh $(DS_HOST) " \ @ssh $(DS_HOST) " \
cd $(DS_PATH) && \ cd $(DS_PATH) && \
$(DOCKER) compose build --no-cache" $(DOCKER) compose build"
# ---------------------------------------------------------- # ----------------------------------------------------------
# STOP # STOP