# Harbor Desk deploy helpers
# 用法：make -C deploy restart

.PHONY: env redeploy redeploy-keep restart wipe infra migrate build start stop status nginx help

SCRIPTS := ./scripts

help:
	@echo "常用："
	@echo "  make restart        # 只重編+重開 gateway/worker/web（保留資料）★ 日常開發"
	@echo "  make status         # 看埠 / pid / 健康"
	@echo "  make stop | start   # 只停 / 只起 app"
	@echo "  make build          # 只編譯"
	@echo ""
	@echo "重裝（會動 infra）："
	@echo "  make redeploy-keep  # 保留 DB，重跑 migrate+build+start"
	@echo "  make redeploy       # 清 volume + 全重建（危險）"
	@echo "  make wipe | infra | migrate | env | nginx"

env:
	@if [ ! -f .env.dev ]; then \
	  cp .env.example .env.dev; \
	  echo "created deploy/.env.dev — 請改密鑰"; \
	else \
	  echo "deploy/.env.dev already exists"; \
	fi

# 日常開發：不動 Mongo/Redis/MinIO 資料
restart:
	$(SCRIPTS)/restart.sh

redeploy:
	$(SCRIPTS)/redeploy.sh --yes --kill-orphan

redeploy-keep:
	$(SCRIPTS)/redeploy.sh --yes --keep-data

wipe:
	$(SCRIPTS)/wipe.sh --yes --kill-orphan

infra:
	$(SCRIPTS)/up-infra.sh

migrate:
	$(SCRIPTS)/migrate.sh

build:
	$(SCRIPTS)/build.sh

start:
	$(SCRIPTS)/start.sh

stop:
	$(SCRIPTS)/stop.sh

status:
	$(SCRIPTS)/status.sh

nginx:
	$(SCRIPTS)/install-nginx.sh
