-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (69 loc) · 1.86 KB
/
Makefile
File metadata and controls
80 lines (69 loc) · 1.86 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
# Node Dashboard Makefile
# Variables
BINARY_NAME=node-dashboard
MAIN_PATH=./cmd/node-dashboard
BUILD_DIR=./build
# Default target
.PHONY: all
all: build
# Development build
.PHONY: build
build:
@echo "Building for development..."
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH)
@echo "Development build complete: $(BUILD_DIR)/$(BINARY_NAME)"
# Production build (Linux executable for Docker)
.PHONY: build-prod
build-prod:
@echo "Building for production (Linux)..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o $(BUILD_DIR)/$(BINARY_NAME)-linux $(MAIN_PATH)
@echo "Production build complete: $(BUILD_DIR)/$(BINARY_NAME)-linux"
# Run the application in development mode
.PHONY: run
run: build
@echo "Running node-dashboard..."
$(BUILD_DIR)/$(BINARY_NAME) --port 8080 --node-exporter http://localhost:9100
# Clean build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR)
rm -f node-dashboard
@echo "Clean complete"
# Install dependencies
.PHONY: deps
deps:
@echo "Installing dependencies..."
go mod tidy
go mod download
@echo "Dependencies installed"
# Format code
.PHONY: fmt
fmt:
@echo "Formatting code..."
go fmt ./...
@echo "Code formatted"
# Run tests
.PHONY: test
test:
@echo "Running tests..."
go test -v ./...
@echo "Tests complete"
# Build and run
.PHONY: dev
dev: build run
# Help target
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build for development"
@echo " build-prod - Build for production (Linux executable)"
@echo " run - Run the application"
@echo " dev - Build and run in development mode"
@echo " clean - Clean build artifacts"
@echo " deps - Install dependencies"
@echo " fmt - Format code"
@echo " test - Run tests"
@echo " help - Show this help message"