-include .env
export

SSH := $(REMOTE_USER)@$(REMOTE_HOST)
WEBROOT := $(REMOTE_HOME)/public_html

# Local dev
start:
	docker compose up -d

stop:
	docker compose down

setup: start install-plugins

install-plugins:
	docker exec natascha_grav php /app/www/public/bin/gpm install $(shell cat plugins.txt | tr '\n' ' ') -y

# Content (user repo)
content-push:
	git subtree push --prefix=user user-deploy main

content-pull:
	git subtree pull --prefix=user user-deploy main --squash

# Remote
remote-install:
	ssh $(SSH) "WEBROOT=$(WEBROOT) REPO=$(REPO) GRAV_VERSION=$(GRAV_VERSION) PLUGINS='$(shell cat plugins.txt | tr '\n' ' ')' GITEA_HOST=$(GITEA_HOST) GITEA_USER=$(GITEA_USER) GITEA_TOKEN=$(GITEA_TOKEN) bash -s" < scripts/server-install.sh

remote-deploy:
	ssh $(SSH) "cd $(WEBROOT)/user && git pull && cd $(WEBROOT) && php bin/gpm install $(shell cat plugins.txt | tr '\n' ' ') -y"

remote-install-plugins:
	ssh $(SSH) "cd $(WEBROOT) && php bin/gpm install $(shell cat plugins.txt | tr '\n' ' ') -y"

remote-upgrade-grav:
	ssh $(SSH) "cd $(WEBROOT) && php bin/grav upgrade"

remote-clean:
	ssh $(SSH) "cd $(WEBROOT) && php bin/grav clearcache"
