-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (97 loc) · 4.44 KB
/
Copy pathMakefile
File metadata and controls
120 lines (97 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ─────────────────────────────────────────────────────────────────────────────
# Kylrix — Makefile
# Self-hosting management commands
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: help setup mint bootstrap up down logs build restart status app-only clean backup update schema-push upgrade-appwrite install
# Compose reads shell exports before .env — load minted values in the same shell as compose.
define WITH_ENV
set -a && . ./selfhost/load-env.sh .env && set +a &&
endef
help: ## Show this help message
@echo ""
@echo " Kylrix Self-Hosting"
@echo " ─────────────────────────────────────"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
COMPOSE := docker compose
COMPOSE_FULL := $(COMPOSE) -f docker-compose.yml
COMPOSE_APP := $(COMPOSE) -f docker-compose.yml -f docker-compose.app-only.yml
BACKUP_DIR := ./backups/$(shell date +%Y%m%d_%H%M%S)
setup: ## Interactive setup wizard — generates .env with secure defaults
@bash selfhost/setup.sh
mint: ## Mint non-interactive .env secrets + local project ID
@bash selfhost/mint-env.sh
install: ## One-command self-host install (same as curl | bash selfhost.sh)
@bash selfhost.sh
bootstrap: mint ## Start Appwrite infra and mint local project + API key
@$(COMPOSE_FULL) up -d mariadb redis appwrite
@bash selfhost/bootstrap.sh
up: bootstrap ## Start full stack (infra bootstrap + Kylrix build + schema)
@$(WITH_ENV) $(COMPOSE_FULL) up -d --build kylrix
@bash selfhost/provision-schema.sh || echo " ⚠ Schema provisioning did not finish — re-run: make schema-push"
@echo ""
@echo " ✓ Kylrix is starting at http://localhost:$${APP_PORT:-5003}"
@echo " ✓ Appwrite API at http://localhost:$${APPWRITE_PORT:-8080}/v1"
@echo ""
down: ## Stop all services
$(COMPOSE_FULL) down
logs: ## Follow logs from all services
$(COMPOSE_FULL) logs -f
build: ## Rebuild the Kylrix image
$(COMPOSE_FULL) build --no-cache kylrix
restart: down up ## Restart all services
status: ## Show service status and health
@echo ""
$(COMPOSE_FULL) ps
@echo ""
app-only: ## Start Kylrix only (external Appwrite — set APPWRITE_ENDPOINT in .env)
$(COMPOSE_APP) up -d --build
@echo ""
@echo " ✓ Kylrix (app-only mode) is starting up..."
@echo " Make sure APPWRITE_ENDPOINT in .env points to your Appwrite instance."
@echo ""
clean: ## Remove all containers, images, and volumes (DESTRUCTIVE)
@echo "⚠ This will destroy all data volumes. Press Ctrl+C to abort."
@sleep 5
$(COMPOSE_FULL) down -v --rmi local --remove-orphans
@echo " ✓ Cleaned up"
backup: ## Backup persistent volumes to ./backups/
@mkdir -p $(BACKUP_DIR)
@echo " Backing up volumes to $(BACKUP_DIR)..."
@for vol in mariadb_data redis_data appwrite_uploads appwrite_config caddy_data; do \
echo " → $$vol"; \
docker run --rm \
-v kylrix-net_$$vol:/source:ro \
-v $(shell pwd)/$(BACKUP_DIR):/backup \
alpine tar czf /backup/$$vol.tar.gz -C /source . 2>/dev/null || \
docker run --rm \
-v $$vol:/source:ro \
-v $(shell pwd)/$(BACKUP_DIR):/backup \
alpine tar czf /backup/$$vol.tar.gz -C /source . 2>/dev/null || \
echo " (skipped — volume not found)"; \
done
@echo ""
@echo " ✓ Backups saved to $(BACKUP_DIR)"
@echo ""
update: ## Pull latest images, rebuild, and restart
@echo " Pulling latest base images..."
$(COMPOSE_FULL) pull --ignore-buildable
@echo " Rebuilding Kylrix..."
$(COMPOSE_FULL) build kylrix
@echo " Restarting services..."
$(COMPOSE_FULL) up -d
@echo ""
@echo " ✓ Update complete"
@echo ""
schema-push: ## Provision Appwrite databases, tables, and storage buckets
@bash selfhost/provision-schema.sh
upgrade-appwrite: mint ## Pull latest Appwrite image, migrate DB, restart stack
@bash selfhost/upgrade-appwrite.sh
logs-kylrix: ## Follow logs for the Kylrix app only
$(COMPOSE_FULL) logs -f kylrix
logs-appwrite: ## Follow logs for Appwrite only
$(COMPOSE_FULL) logs -f appwrite
shell: ## Open a shell in the running Kylrix container
docker exec -it kylrix-app sh