-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (98 loc) · 3.16 KB
/
Copy pathMakefile
File metadata and controls
122 lines (98 loc) · 3.16 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
SHELL := /bin/bash
COMPOSE := docker compose -f docker-compose.yaml
MODULE_DIRS := \
backend/app-modules/app-kernel \
backend/app-modules/app-system-module \
backend/app-modules/app-user-module \
backend/app-modules/app-auth-module \
backend/app-modules/app-account-module \
backend/app-modules/app-analytics-module \
backend/app-modules/app-blog-module \
backend/app-modules/app-media-module \
backend/app-modules/app-redirect-module \
backend/app-modules/app-web-module
TEST_PACKAGE_DIRS := backend $(sort $(dir $(wildcard backend/app-modules/*/Package.swift)))
DEPS_SERVICES := certificates postgres migrator
BACKEND_SERVICES := $(DEPS_SERVICES) server worker
ALL_SERVICES := certificates postgres migrator server worker web-static openapi-app openapi-admin web-app
POSTGRES_VOLUME := feather-cms-postgres-data
MEDIA_VOLUME := feather-cms-file-storage
.PHONY: up up-build down stop logs ps restart pull config clean reset deps all backend web-static backend-logs test test-all format fix-headers docker-up docker-down $(SERVICE_TARGETS)
define detect_lan_host
iface="$$(route -n get default 2>/dev/null | awk '/interface: / { print $$2; exit }')"; \
if [ -n "$$iface" ]; then \
ip="$$(ipconfig getifaddr "$$iface" 2>/dev/null || true)"; \
fi; \
if [ -z "$$ip" ]; then \
ip="$$(ifconfig | awk '/inet (192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)/ { print $$2; exit }')"; \
fi; \
printf '%s' "$$ip"
endef
define run_all_services_with_public_origins
@LAN_HOST="$${LAN_HOST:-$$($(detect_lan_host))}"; \
if [ -n "$$LAN_HOST" ]; then \
echo "Using LAN host $$LAN_HOST for public origins"; \
WEB_PUBLIC_BASE_URL="$${WEB_PUBLIC_BASE_URL:-http://$$LAN_HOST:3456}" \
STATIC_PUBLIC_BASE_URL="$${STATIC_PUBLIC_BASE_URL:-http://$$LAN_HOST:4567}" \
MEDIA_PUBLIC_BASE_URL="$${MEDIA_PUBLIC_BASE_URL:-http://$$LAN_HOST:8080}" \
$(COMPOSE) up --build $(ALL_SERVICES); \
else \
echo "LAN host detection failed, using configured/default public origins"; \
$(COMPOSE) up --build $(ALL_SERVICES); \
fi
endef
up:
$(COMPOSE) up
up-build:
$(COMPOSE) up --build
down:
$(COMPOSE) down
stop:
$(COMPOSE) stop
logs:
$(COMPOSE) logs -f
ps:
$(COMPOSE) ps
restart:
$(COMPOSE) restart
pull:
$(COMPOSE) pull
config:
$(COMPOSE) config
clean:
$(COMPOSE) down --remove-orphans
docker volume rm -f $(POSTGRES_VOLUME) $(MEDIA_VOLUME) 2>/dev/null || true
reset:
$(COMPOSE) down --remove-orphans --volumes
deps:
$(COMPOSE) up -d --build $(DEPS_SERVICES)
test:
$(MAKE) -C backend test
test-all:
@set -e; \
for package in $(TEST_PACKAGE_DIRS); do \
echo "Testing $$package"; \
if [ -f "$$package/Makefile" ]; then \
$(MAKE) -C "$$package" test; \
else \
(cd "$$package" && swift test --parallel); \
fi; \
done
docker-up:
$(COMPOSE) up -d certificates postgres
@for module in $(MODULE_DIRS); do \
$(MAKE) -C $$module docker-up; \
done
docker-down:
@for module in $(MODULE_DIRS); do \
$(MAKE) -C $$module docker-down; \
done
$(COMPOSE) down -v --remove-orphans
all:
$(run_all_services_with_public_origins)
backend:
$(COMPOSE) up --build $(BACKEND_SERVICES)
backend-logs:
$(COMPOSE) logs -f migrator server worker web-static openapi-app openapi-admin
$(ALL_SERVICES):
$(COMPOSE) up --build $@