-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (49 loc) · 1.65 KB
/
Makefile
File metadata and controls
60 lines (49 loc) · 1.65 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
# Ensure bash_history file exists before build
BASH_HISTORY_FILE=./utils/bash_history
# All services
ALL_SERVICES=perl_modules_builder db mqtt web meter_grapher mysql_mqtt_command_queue_receive mysql_mqtt_command_queue_send smsd meter_sms meter_cron redis postfix
OTHER_SERVICES=$(filter-out perl_modules_builder,$(ALL_SERVICES))
# Default target
all: build up
# Build target: build and run perl_modules_builder first, then build other services
build: $(BASH_HISTORY_FILE)
@echo "Building and starting perl_modules_builder..."
docker compose build perl_modules_builder
docker compose up -d perl_modules_builder
@echo "Building remaining services..."
docker compose build $(OTHER_SERVICES)
# Start all other services (after build)
up:
@echo "Starting all other services..."
docker compose up -d $(OTHER_SERVICES)
# Log a specific service
log:
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
echo "Usage: make log <service>"; \
exit 1; \
fi
docker compose logs -f $(filter-out $@,$(MAKECMDGOALS))
logs:
docker compose logs -f
down:
docker compose down
top:
docker stats $(ALL_SERVICES)
# Automatically create bash_history file if missing
$(BASH_HISTORY_FILE):
@mkdir -p ./utils
@touch $(BASH_HISTORY_FILE)
@echo "Created $(BASH_HISTORY_FILE) if it did not exist"
# Redeploy a specific service
redeploy:
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
echo "Usage: make redeploy <service>"; \
exit 1; \
fi
git pull
docker compose build $(filter-out $@,$(MAKECMDGOALS))
docker compose down $(filter-out $@,$(MAKECMDGOALS))
docker compose up -d $(filter-out $@,$(MAKECMDGOALS))
# Prevent make from treating service names as targets
%:
@: