-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (111 loc) · 4.2 KB
/
Copy pathMakefile
File metadata and controls
133 lines (111 loc) · 4.2 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
121
122
123
124
125
126
127
128
129
130
131
132
133
.PHONY: help local local-down run deploy down restart reload build logs shell health check-config status clean test
# Variables
COMPOSE := docker compose
CONTAINER := upfusion-api
NETWORK := www-network
# Default target
help:
@echo "Upfusion Audio API"
@echo ""
@echo "Local:"
@echo " make local Start locally (port 8080)"
@echo " make local-down Stop local instance"
@echo ""
@echo "Production:"
@echo " make run Start container"
@echo " make deploy Recreate with fresh config (near-zero downtime)"
@echo " make build Rebuild image from scratch (no cache)"
@echo " make down Stop container"
@echo " make restart Restart container"
@echo " make reload Reload nginx config without restart"
@echo ""
@echo "Monitoring:"
@echo " make logs Follow container logs"
@echo " make shell Open shell in container"
@echo " make health Check health endpoint"
@echo " make status Show container status"
@echo " make check-config Validate nginx config"
@echo ""
@echo "Testing:"
@echo " make test Run all endpoint tests"
@echo ""
@echo "Cleanup:"
@echo " make clean Stop and remove containers"
# ── Local Development ──
local:
@echo "Starting locally on port 8080..."
$(COMPOSE) -f docker-compose.yml -f docker-compose.local.yml up -d
@echo "✓ Running at http://127.0.0.1:8080"
@echo " Health: http://127.0.0.1:8080/health"
@echo " Stream: http://127.0.0.1:8080/stream/upfusion/alternative/axiom"
local-down:
@echo "Stopping local instance..."
$(COMPOSE) -f docker-compose.yml -f docker-compose.local.yml down
@echo "✓ Stopped"
# ── Production ──
run:
@echo "Starting on server..."
$(COMPOSE) up -d
@echo "✓ Running on www-network"
@echo " Health: make health"
deploy:
@echo "Deploying (fresh config)..."
$(COMPOSE) up -d --force-recreate
@echo "✓ Deployed with fresh config"
build:
@echo "Building with no cache..."
$(COMPOSE) build --no-cache
@echo "✓ Built"
down:
@echo "Stopping..."
$(COMPOSE) down
@echo "✓ Stopped"
restart:
@echo "Restarting..."
docker restart $(CONTAINER)
@echo "✓ Restarted"
reload: check-config
@echo "Reloading nginx config..."
docker exec $(CONTAINER) nginx -s reload
@echo "✓ Reloaded"
# ── Monitoring ──
check-config:
@echo "Validating nginx config..."
@docker exec $(CONTAINER) nginx -t
@echo "✓ Config valid"
logs:
docker logs -f $(CONTAINER)
shell:
docker exec -it $(CONTAINER) /bin/sh
health:
@docker exec $(CONTAINER) wget -qO- http://127.0.0.1:8080/health && echo " ✓ healthy" || echo "✗ not responding"
status:
@docker ps --filter name=$(CONTAINER) --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
# ── Testing ──
test:
@echo "── Health ──"
@docker exec $(CONTAINER) wget -qO- http://127.0.0.1:8080/health && echo " ✓" || echo " ✗"
@echo ""
@echo "── Stream with valid referer ──"
@docker exec $(CONTAINER) wget -qS --header="Referer: https://upfusion.net/" -O /dev/null http://127.0.0.1:8080/stream/upfusion/alternative/axiom 2>&1 | head -1
@echo ""
@echo "── Stream without referer (expect 403) ──"
@docker exec $(CONTAINER) wget -qS -O /dev/null http://127.0.0.1:8080/stream/upfusion/alternative/axiom 2>&1 | head -1
@echo ""
@echo "── Alternative tracks ──"
@for track in orthopraxy genome extinction axiom noir; do \
docker exec $(CONTAINER) wget -qO /dev/null --header="Referer: https://upfusion.net/" http://127.0.0.1:8080/stream/upfusion/alternative/$$track 2>/dev/null \
&& echo " ✓ $$track" || echo " ✗ $$track"; \
done
@echo ""
@echo "── Jazz tracks ──"
@for track in spring-vibes d-flat-jazz cronus-fall hypnos-prelude poseidon-ocean axiom noir sigma; do \
docker exec $(CONTAINER) wget -qO /dev/null --header="Referer: https://upfusion.net/" http://127.0.0.1:8080/stream/upfusion/jazz/$$track 2>/dev/null \
&& echo " ✓ $$track" || echo " ✗ $$track"; \
done
# ── Cleanup ──
clean:
@echo "Cleaning up..."
$(COMPOSE) -f docker-compose.yml -f docker-compose.local.yml down --remove-orphans 2>/dev/null; true
$(COMPOSE) down --remove-orphans 2>/dev/null; true
@echo "✓ Cleaned"