-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
123 lines (93 loc) · 4.21 KB
/
Makefile
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
121
122
123
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
PYTHON:=$(ROOT_DIR)/.venv/bin/python
SHELL:=/bin/bash
##@ Homelab 🐳
.PHONY: update
update: ## Update the service(s) *
docker compose --project-directory "$(ROOT_DIR)" --profile all pull $(APP)
docker compose --project-directory "$(ROOT_DIR)" --profile all up -d $(APP)
.PHONY: pull
pull: ## Pull the latest image(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all pull $(APP)
.PHONY: up
up: ## Start the service(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all up -d $(APP) $(ARGS)
.PHONY: down
down: ## Stop the service(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all down $(APP) $(ARGS)
.PHONY: stop
stop: ## Stop the service(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all stop $(APP) $(ARGS)
.PHONY: logs
logs: ## Show the logs*
docker compose --project-directory "$(ROOT_DIR)" --profile all logs $(APP) -ft $(ARGS)
.PHONY: restart
restart: ## Restart the service(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all restart $(APP) $(ARGS)
.PHONY: ps
ps: ## Show the status of the service(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all ps --format "table {{.Image}}\t{{.Status}}\t{{.Ports}}\t{{.Name}}"
.PHONY: config
config: ## Show the configuration of the service(s)*
docker compose --project-directory "$(ROOT_DIR)" --profile all config $(APP) $(ARGS)
##@ Core Services 🧠
.PHONY: core-up
core-up: ## Start just the core services (traefik, oauth2, etc).
docker compose --project-directory "$(ROOT_DIR)" --profile core up -d
.PHONY: core-down
core-down: ## Stop just the core services (traefik, oauth2, etc).
docker compose --project-directory "$(ROOT_DIR)" --profile core down
.PHONY: core-logs
core-logs: ## Show the logs for the core services (traefik, oauth2, etc).
docker compose --project-directory "$(ROOT_DIR)" --profile core logs -ft
##@ Media Services 📺
.PHONY: media-up
media-up: ## Start just the media services (plex, sonarr, radarr, etc).
docker compose --project-directory "$(ROOT_DIR)" --profile media up -d
.PHONY: media-down
media-down: ## Stop just the media services (plex, sonarr, radarr, etc).
docker compose --project-directory "$(ROOT_DIR)" --profile media down
.PHONY: media-logs
media-logs: ## Show the logs for the media services (plex, sonarr, radarr, etc).
docker compose --project-directory "$(ROOT_DIR)" --profile media logs -ft
.PHONY: Misc Services 🧰
##@ Configuration 🪛
.PHONY: config-acme
config-acme: ## Initialize the acme.json file.
mkdir -p appdata/traefik/acme/
rm -f appdata/traefik/acme/acme.json
touch appdata/traefik/acme/acme.json
chmod 600 appdata/traefik/acme/acme.json
##@ Backup 🗂️
.PHONY: backup
backup: ## Backup the homelab repo to the ${BACKUP_DIR}.
bash $(ROOT_DIR)/scripts/backup.sh $(ROOT_DIR)/appdata $(BACKUP_DIR)
.PHONY: backup-no-timestamp
backup-no-timestamp: ## Backup the homelab repo to the ${BACKUP_DIR} without a timestamp.
bash $(ROOT_DIR)/scripts/backup.sh $(ROOT_DIR)/appdata $(BACKUP_DIR) --no-timestamp
##@ Development 🛠
.PHONY: docs
docs: ## Build the documentation.
hatch run docs:serve --livereload --dev-addr localhost:8000
.PHONY: lint
lint: ## Lint the code with pre-commit.
pre-commit run --all-files
##@ General 🌐
.PHONY: version
version: ## Show the version of the project.
@git fetch --unshallow 2>/dev/null || true
@git fetch --tags 2>/dev/null || true
@echo "homelab $$(git describe --tags --abbrev=0)"
################################################
# Auto-Generated Help:
# - "##@" denotes a target category
# - "##" denotes a specific target description
###############################################
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help message and exit
@printf "\033[1;34mUsage:\033[0m \033[1;32mhomelab\033[0m \033[1;33m[target]\033[0m \033[1;36m(APP=service-name)\033[0m\n"
@echo ""
@printf "* pass \033[1;36mAPP=service-name\033[0m to specify the service\n"
@printf "* pass \033[1;36mARGS=arguments\033[0m to specify additional arguments\n"
@awk 'BEGIN {FS = ":.*##"; printf ""} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-19s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)