-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (42 loc) · 1.16 KB
/
Makefile
File metadata and controls
53 lines (42 loc) · 1.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
# Variables
BINARY_NAME=loki-ingest
BIN_DIR=bin
CMD_DIR=./cmd/server
DOCKER_IMAGE=loki-ingest
DOCKER_TAG=latest
.PHONY: help build run test clean docker
help: ## Display this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
build: ## Build the application binary
@echo "Building application..."
@mkdir -p $(BIN_DIR)
CGO_ENABLED=0 go build \
-trimpath \
-ldflags="-s -w" \
-o $(BIN_DIR)/$(BINARY_NAME) \
$(CMD_DIR)
run: ## Run the application locally
@echo "Running application..."
go run $(CMD_DIR)/main.go
test: ## Run tests
@echo "Running tests..."
go test -v ./...
clean: ## Clean build artifacts
@echo "Cleaning..."
rm -rf $(BIN_DIR)/
go clean
deps: ## Download dependencies
@echo "Downloading dependencies..."
go mod download
go mod tidy
docker: ## Build Docker image
@echo "Building Docker image..."
docker build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
lint: ## Run linters
@echo "Running linters..."
golangci-lint run
fmt: ## Format code
@echo "Formatting code..."
go fmt ./...
all: clean deps build ## Clean, download deps, and build