-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (53 loc) · 1.31 KB
/
Makefile
File metadata and controls
73 lines (53 loc) · 1.31 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
DAEMON_BINARY=bin/nendo-daemon
CLI_BINARY=bin/nendo-cli
DAEMON_SRC=./cmd/nendo/daemon
CLI_SRC=./cmd/nendo/cli
PROTO_DIR=internal/api
GO_BUILD_ENV=CGO_ENABLED=1 GOOS=linux GOARCH=amd64
.PHONY: all build clean proto run-daemon check-root count
all: build
build: build-daemon build-cli
build-daemon:
@echo "Building daemon..."
mkdir -p bin
$(GO_BUILD_ENV) go build -o $(DAEMON_BINARY) $(DAEMON_SRC)
build-cli:
@echo "Building cli..."
mkdir -p bin
$(GO_BUILD_ENV) go build -o $(CLI_BINARY) $(CLI_SRC)
proto:
@echo "Generating protobuf code..."
buf dep update
buf generate $(PROTO_DIR)
tidy:
@echo "Tidying go modules..."
go mod tidy
daemon: build
@echo "Starting daemon..."
sudo ./$(DAEMON_BINARY)
clean:
@echo "Cleaning up..."
rm -rf bin
sudo rm -rf /var/lib/nendo
sudo rm -f /run/nendo.sock
check-root:
@if [ "$$(id -u)" -ne 0 ]; then \
echo "Error: This command must be run as root (use sudo)."; \
exit 1; \
fi
# 実行例: make pull image=alpine:latest
pull: build-cli
./$(CLI_BINARY) pull $(image)
# 実行例: make run image=ubuntu:latest id=test cmd="/bin/sleep 1000"
run:
./$(CLI_BINARY) run $(image) $(id) $(cmd)
list:
./$(CLI_BINARY) list
stop:
./$(CLI_BINARY) stop $(id)
# 実行例: make rm id=test
rm:
./$(CLI_BINARY) rm $(id)
count:
@echo "Counting lines of code..."
cloc $(HOME)/nendo